I need to redirect trailing slash exact URL ( www.xyz.com/registration/ ) to non-slash ( www.xyz.com/registration ) with httaccess. But only this exact URL, not any other. How to do it?
Asked
Active
Viewed 51 times
1 Answers
-1
If you want to do a 301 redirect to a specific URL:
RedirectMatch 301 ^/registration/$ /registration

Valeriu Ciuca
- 2,084
- 11
- 14
-
Apart from the fact that this does not need `RewriteEngine On` (because `RedirectMatch` is not provided by mod_rewrite in the first place), this matches more than just the one specific URL wanted here. If the requested URL was `/registration/foobar`, then this would redirect to `/registrationfoobar` – CBroe Oct 18 '22 at 10:46
-
And it would even match on `/foobar/registration/baz`, redirecting to `/foobar/registrationbaz`. This needs _anchoring_ of the pattern at the beginning and end. `RedirectMatch 301 ^/registration/$ /registration` – CBroe Oct 18 '22 at 10:48
-
I know man, it was written on the go, and now is correct, before you posted the second comment. – Valeriu Ciuca Oct 18 '22 at 10:49