RedirectMatch in htaccess with & characters

RedirectMatch in htaccess with & characters

We had a problem with the contents of our htaccess file which required RedirectMatch URIs to contain & symbols.  This was creating all sorts of problems with the resulting URL appearing in the browser.

e.g.

RedirectMatch ^/eveningclasses$ http://192.168.41.66/dumgalportal/index.php?pageid=evening.cts&site=cts

The &site=cts part is lost and the word eveningclasses is appearing in place of the & before the word site. There are many solutions on the web involving Apache configuration, ReWrite rules etc. But there is a much simpler solution available:

Double escape ‘&’ symbols in the htaccess file.

RedirectMatch ^/eveningclasses$ http://192.168.41.66/dumgalportal/index.php?pageid=evening.cts\\&site=cts

The redirect now works as anticipated.

Leave a Reply

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

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.