Hans Wassink Hans Wassink - 10 days ago 4x
Apache Configuration Question

301 redirect urls with a slash in querystring

We built a new webshop for one of our clients, and are 301 redirecting their old url's to our normal ones. As usual we do this using .htaccess as follows:

Redirect 301 /url1/ http://www.url2.com/
and it works fine.

BUT the old shop has this querystring with slashes in it (!) , for example:


And as soon as I use this in a htaccess 301 redirect string it stops working. I don't get a 500 error or something like that, but when I visit
it won't redirect. If I would use it with a querystring like the following (
) I can visit it and get redirected, but not if there's a slash in it.

I tried backslashing it, encoding etc. but without the right results. Does any1 have an idea? I tried
AllowEncodedSlashes On
but it gave me a 500 error.


Since you cannot match QUERY_STRING in Redirect directive, you need to use mod_rewrite based rule.

Have this one in your root .htaccess:

RewriteEngine On

RewriteCond %{QUERY_STRING} ObjectPath=/Shops/61922345/Products/32428
RewriteRule ^/?epages/14353\.sf/de_DE/?$ https://www.nu.nl? [L,NC,R=301]

Make sure to test this in a new browser to avoid old cached data.