Remove trailing slash from real directories

冷暖自知 提交于 2019-12-13 18:27:21

问题


how are you? please one very little question if you don't mind.

after the previous episode of redirecting and rewriting rules in this thread: redirect to default language except for /amp/ Urls, our SEO agency recommended us to change the URLs site.com/fr, site.com/be to site.fr and site.be

I already set the 301 redirections for old URLs as follow:

RewriteRule ^[a-z]{2}$ / [R=301,L]
RewriteRule ^[a-z]{2}/(.*)$ /$1 [R=301,L]

I know this can be achieved in one rule but didn't manage to make it work :/

since I now removed the language folder, removing the trailing slash does't really work well. site.com/test adds the slash because the folder "test" exists and is a real folder. I tried DirectorySlash Off but it returns a forbidden 403 error. please any idea how to solve this?

Thanks a lot


回答1:


Following my comments:

Combining those 2 shown rules into one:

RewriteRule ^[a-z]{2}(?:/(.*))?$ /$1 [R=301,L,NE]


来源:https://stackoverflow.com/questions/53635598/remove-trailing-slash-from-real-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!