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 ^(.*)\/(\?.*)?$ $1$2 [R=301,L])However I only want to do it if that directory is /abc/For example:http://www.example.com/abc/cowboy/ should be 301ed to http://www.example.com/abc/cowboyhttp://www.example.com/xyz/cowboy/ should stay the same and NOT be 301ed
Removing trailing slash ONLY for a specific directory
redirects;apache;301 redirect
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/$1$2 [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.