Redirecting a URL with a query string to a static URL

Discuss practical ways rearrange URLs using mod_rewrite.

Redirecting a URL with a query string to a static URL

Postby DaileyDev » Fri Sep 19, 2008 11:03 am

I need to redirect one URL to another. I'm thinking mod_rewrite can do this, but I haven't been able to get it to work yet.

From this URL:
http://mydomain.com/ucp.php?mode=register

To this URL:
http://mydomain.com/register.html

The idea is to redirect the requests to use the "register" module on the fourms to a new URL. Any guidance would be appreciated.
DaileyDev
 
Posts: 2
Joined: Fri Sep 19, 2008 10:58 am

Postby richardk » Fri Sep 19, 2008 1:49 pm

To match a query string variable you have to use a RewriteCond and %{QUERY_STRING}
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?mode=register(&.*)?$ [NC]
RewriteRule ^ucp\.php$ /register.html [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby DaileyDev » Fri Sep 19, 2008 2:49 pm

Thank works great. Thanks for your help!

Bill
DaileyDev
 
Posts: 2
Joined: Fri Sep 19, 2008 10:58 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 19 guests

cron