Reputation: 69
I have to addresses for one site (different langs) and I need a redirect with saving query string. So I need to catch this
http://www.example1.kereell.com/wp-login.php?action=logout&redirect_to=http%253A%252F%252Fwww.example2.kereell.com%252Fafiliados-de-la-zona%252F&_wpnonce=66909cdca0
and redirect to
http://www.example2.kereell.com/wp-login.php?action=logout&redirect_to=http%253A%252F%252Fwww.example2.kereell.com%252Fafiliados-de-la-zona%252F&_wpnonce=66909cdca0
in .htaccess file it should be something like this
RewriteCond %{HTTP_HOST} ^.*example1\.kereell\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-login.php?action=logout&redirect_to=http%3A%2F%2Fwww.example2.kereell.com%2Fafiliados-de-la-zona%2F&_wpnonce=66909cdca0$ [NC]
RewriteRule ^(.*)$ http://www.example2.kereell.com/$1 [R=301,L]
I tried a lot of everything (escaping "%", regex classes) but didn't get it to work because of urlencoded characters. If I replace all urlencoded symbols - it works..
Upvotes: 2
Views: 1303
Reputation: 69
So the solution was really easy as it suppose to be:
RewriteCond %{HTTP_HOST} ^.*example1\.kereell\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-login.php$ [NC]
RewriteCond %{QUERY_STRING} ^action=logout&redirect_to=http[\%A-Z0-9]*www.example2.kereell.com(.*)$ [NC]
RewriteRule ^(.*)$ http://www.example2.kereell.com/$1 [R=301,L]
Thanks for Qtax that paid my attention to QUERY_STRING!
Upvotes: 1