htaccess Redirect only exact url match

I use a lot of redirecting, a result of site evolution over time – moving from one CMS to another, having multiple languages on my site etc.  Most of the time I simply used:

I use clean url (there are no extensions at the end) and sometimes the structure hierarchy gets complicated and some links under the parent’s structure don’t need a redirect while their parent do need it. For those cases an exact redirect is needed so only the parent will be redirected without affecting its kids. I use redirectMatch 301 for that:

Note the “^” at the beginning and “$” at the end of the exact match.

Leave a Reply

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