Reputation: 3210
I've researched this for awhile now and swear my solution should work according to the following (and hundreds of others here so forgive my duplication):
I need to remove the query string from a redirect. Old WordPress ?p=### to a new domain/url.
Old Url: blog.domain.com/blog/?p=123
New Url: www.domain.com/yada/woohoo/
With this:
RewriteCond %{QUERY_STRING} ^p=123$
RewriteRule ^/blog/$ http://www.domain.com/yada/woohoo/? [L,R=301]
I get: http://www.domain.com/yada/woohoo/?p=123
I want: http://www.domain.com/yada/woohoo/
blog.domain.com will be redirected at the DNS level.
What am I missing? The "?" at the end of the rewrite line should remove the query string?
Upvotes: 0
Views: 2384
Reputation: 307
I just tried your code, the only thing i changed was the first / in blog, and i got it working perfectly, without the querystring
If you're running Apache > 2.4 then you can use the flag QSD, but otherwise, with the ? at the end it works. Is there any other rules there?
RewriteCond %{QUERY_STRING} ^p=123$
RewriteRule ^blog/$ http://www.domain.com/yada/woohoo/? [L,R=301]
Upvotes: 1