Please throw me a mod_rewrite bone

megatabbers

New member
Jul 21, 2009
1,284
29
0
Boston, MA
Trying to get domain.com/keyword to rewrite to domain.com/index.php?id=keyword

Using the following code but not working:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/(.*)$ index.php?id=$1 [L]

What am I missing here?
 


Very odd. None of the suggestions work. The only way I've gotten it to work is if I add
another something before the slash (e.g. RewriteRule ^something/(.*)$ index.php?id=$1 [QSA] )
 
Remove the forward slash from the regex in the rewrite rule

RewriteRule ^/(.*)$ index.php?id=$1 [L]

should be

RewriteRule ^(.*)$ index.php?id=$1 [L]
 
for some reason the ID variable won't pass correctly without the query string append:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?id=$1 [QSA]

that should work (the RewriteBase / may not be needed if you aren't using RS cloud)
 
for some reason the ID variable won't pass correctly without the query string append:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?id=$1 [QSA]

that should work (the RewriteBase / may not be needed if you aren't using RS cloud)

This seems to work. Thanks. Now the only the only thing that needs changing
is my img urls from relative to absolute. For some reason those get messed up with this new code.