Reputation: 17561
While using a WordPress maintenance plugin, I ended up with this query string URL that I now need to redirect to root when the site goes live.
http://mydomain.com/maintenance/?req=http%3A%2F%mydomain.com%2F
What will redirect that URL to simply http://mydomain.com
?
I've tried both of these:
Redirect 301 "http://mydomain.com/maintenance/?req=http://mydomain.com/" http://mydomain.com
Redirect 301 "http://mydomain.com/maintenance/?req=http%3A%2F%mydomain.com%2f" http://mydomain.com
Upvotes: 1
Views: 1427
Reputation: 786081
Put these lines in your .htaccess file:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} req=http%3A%2F%2F(.+)%2F [OR]
RewriteCond %{QUERY_STRING} req=http://([^&]+)(&|$) [NC]
RewriteRule ^maintenance/?$ http://%1? [L,R,NC,NE]
Upvotes: 2
Reputation: 655735
Redirect
does only work with the URL path. You need to use the real mod_rewrite to look at the query:
RewriteEngine on
RewriteCond %{QUERY_STRING} =req=http://example.com/
RewriteRule ^maintenance/$ /? [L,R=301]
Upvotes: 0