: Removing trailing slash ONLY for a specific directory I would like to 301 redirect my URL that has a trailing slash to a URL without a trailing slash. That part is simple (RewriteRule ^(.*)/(?.*)?$
I would like to 301 redirect my URL that has a trailing slash to a URL without a trailing slash. That part is simple (RewriteRule ^(.*)/(?.*)?$ [R=301,L])
However I only want to do it if that directory is /abc/
For example:
www.example.com/abc/cowboy/ should be 301ed to www.example.com/abc/cowboy http://www.example.com/xyz/cowboy/ should stay the same and NOT be 301ed
More posts by @Barnes591
1 Comments
Sorted by latest first Latest Oldest Best
In your server config, you can modify your current example to include the /abc/ directory to restrict redirects to that one directory:
RewriteRule ^/abc/(.*)/(?.*)?$ /abc/ [R=301,L]
I've removed the backslash escape from the slash, in your example, as this would appear to be unnecessary.
Note that to make this work in .htaccess you would need to removed the slash prefix from the RewriteRule pattern.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.