I know how to remove slashes after url, and i know how to add it also:
# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ /$1 [L,R=301]
# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*[^/]$ /$0/ [L,R=301]
What i want is to remove all slashes so that all urls don't have slashes at the ending, but in one case the url SHOULD contain the slash.
1.) So only in this case it should add a slash:
example.com/en -> example.com/en/
2.) In any other case slash should be removed:
example.com/us/ -> example.com/us
example.com/en/product/ -> example.com/en/product
How to do that with .htaccess rules?