I'm having troubles with my .htaccess permanent redirection code which is not working:
RedirectPermanent ^shop/?attro-attributes=([0-9]*) http://www.second-website.example
I would like to redirect URLs from first-website:
first-website.example/shop/?attro-attributes=01
first-website.example/shop/?attro-attributes=02
first-website.example/shop/?attro-attributes=...
first-website.example/shop/?attro-attributes=9999
to second-website URL: http://www.second-website.example/
RedirectPermanent
and other redirect directives from mod_alias
have no access to the query string. Your match pattern can't contain the ?
from the URL or match on anything after it.
You'll instead have to use mod_rewrite
which can access the query string via RewriteCond
.
RewriteEngine on
RewriteCond %{QUERY_STRING} attro-attributes=[0-9]*
RewriteRule ^/?shop/$ https://www.second-website.example/ [L,R=301]