Forum Moderators: phranque

Message Too Old, No Replies

redirect example.php?name=eg to example/eg

         

junglesnail

4:18 pm on Feb 27, 2010 (gmt 0)

10+ Year Member



Hi guys,

I found on the forum how to rewrite urls to get this. I tried using :
RewriteEngine on
RewriteRule ^name/([^/\.]+)/?$ example.php?name=$1 [L]
and it works.
But how do i actually redirect an user when accessing example.php?name=eg to /example/eg ?
Thank you.

g1smd

7:14 pm on Feb 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This topic comes up every few days.

You need another rule to do the redirect. It will need a RewriteCond to test the query string value, and you need to test that this was a direct client request.

The redirect will be listed before the rewrite.

Don't allow the rewrite to accept an optional trailing slash. Allow only URL requests without trailing slash to trigger the rewrite.

jdMorgan

4:46 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See also the archived thread in our Apache Forum Library titled "Changing Dynamic URLs to static URLs."

Jim