Mod Rewrite Help

Discuss practical ways rearrange URLs using mod_rewrite.

Mod Rewrite Help

Postby amphtech » Sat Mar 28, 2009 3:30 pm

I would like to redirect
Code: Select all
http://www.mydomain.com/main.php?id=home
to
Note: id=pagename will change depending on what page you are loading.
Code: Select all
http://www.mydomain.com/home
with Mod_Rewrite while still leaving all the other folders in the root dir the same so they do not get rewritten.
Help would be appreciated.
Thanks,
Wade
amphtech
 
Posts: 2
Joined: Fri Mar 27, 2009 6:59 pm

Postby richardk » Sat Mar 28, 2009 6:34 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# If it's not a request to an existing file.
RewriteCond %{SCRIPT_FILENAME} !-f
# And if it's not a request to an existing directory.
RewriteCond %{SCRIPT_FILENAME} !-d
# /something to /main.php?id=something
RewriteRule ^([^/]+)/?$ /main.php?id=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby amphtech » Sat Mar 28, 2009 7:42 pm

Works like a charm thanks so much :)
amphtech
 
Posts: 2
Joined: Fri Mar 27, 2009 6:59 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 17 guests

cron