How to configure redirects to url with trailing slash in nginx?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to redirect URLs without slash to the path with trailing slash. So /some-url to /some-url/ And the rest of the URLs, like /some-url.xml /some-url? /some-url?q=v /some-url/ Should stay without redirection. I found this article https://www.ateamsystems.com/tech-blog/nginx-add-trailing-slash-with-301-redirect-without-if-statements/ in which author suggests to use following rule: location ~ ^([^. \? ]*[^/]) $ { try_files $uri @addslash ; } location @addslash { return 301 $uri /; } Unfortunately this doesn't really work. Because