I would like to redirect a top level page using htaccess, but not redirect tier pages. Let me explain. I currently have this redirect in place:
Redirect 301 /support /donate
In summary, I want someone to be redirected to /donate when the visit /support. However, with this rule if someone visits:
https://www.example.com/support/test
They are redirected to:
https://www.example.com/donate/test
I do NOT want them to be redirected in these instances - only if they visit /support or /support/ (note trailing slash).
I'm not sure how to do this or if this is possible. Any ideas?
The
Redirectdirective is prefix-matching, so you will need to use theRedirectMatchdirective instead, which matches against a regex.For example:
The above matches
/supportor/support/only and redirects to/donatein both cases. Note that the previousRedirectdirective would have redirected to/donateor/donate/depending on whether there was a trailing slash on the initial request.You will need to clear your browser cache before testing, since any erroneous 301 (permanent) redirects will have been cached persistently by the browser. Test first with 302s to avoid potential caching issues.
Reference: