tags:

views:

103

answers:

1

Hello,

Having trouble with redirecting a dynamic URL. This is what I want to accomplish:

Redirect 301 /content/index.php?id=423 http://www.domain.com/new-page/

I tried this

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)id=423$
RewriteRule ^content/index\.php$ http://www.domain.com/new-page [L,R=301]

but had no luck. Thank you!

+1  A: 

You need to specify the query in the replacement URL. Otherwise the original query is taken:

RewriteCond %{QUERY_STRING} ^id=423$
RewriteRule ^content/index\.php$ http://example.com/new-page? [L,R=301]

And if you want to preserve other URL arguments, try this:

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)id=423&*([^&].*)?$
RewriteRule ^content/index\.php$ http://example.com/new-page?%1%3 [L,R=301]
Gumbo