Forum Moderators: phranque

Message Too Old, No Replies

rewrite url drop query string parameters

using mod_rewrite dropping query string

         

badgrs

7:08 pm on Feb 21, 2007 (gmt 0)

10+ Year Member



Hi,

I am trying to use mod_rewrite to redirect some old URLs to new ones. I need to redirect a URL like 'services.php?id=2' to simply '/services/all' with no query string parameters. Using the following adds the?id=2 to the end of the URL but I want a fresh redirect without this:
RewriteCond $1 ^services.php(.*)
RewriteRule ^(.*) /services/all [L,R=301]

Can anyone help?

Thanks a lot!

jdMorgan

9:12 pm on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For that exact URL and query string only:

RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^services\.php$ /services/al[b]l?[/b] [R=301,L]

The question mark appended to the substitution URL clears the current query string, as documented in the mod_rewrite manual.

Jim