How do I redirect a URL with encoded characters in Apache?

If you need to redirect a URL with encoded characters you may discover that mod_rewrite does not work well with them.

If your source URL is:

You will notice that a standard redirect will work fine without encoded characters, but as soon as you hit the encoded characters you will get a 404 instead of a redirect.

To get around this problem, you can turn AllowEncodedSlashes on in your VirtualHost.

AllowEncodedSlashes On
RewriteRule ^/somePage/fromURL=(.*) http://mydomain.com [L,R=301]

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top