0

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! ps/ I lost some para work with this code

RewriteRule ^([^.]+)/([A-Za-z]*)-([^.]+)-([0-9]+).html$ $1/$4-$2-$3.html [L,R=301]

1 Answer 1

4

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]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.