How do you fix Nginx automatically 301 redirecting to the same URL with a trailing slash?

我只是一个虾纸丫 提交于 2019-12-02 10:22:15

This is a result of the try_files directive. It's looking for the file named about, and when it fails to find it, it proceeds to look for a folder named about. (The folder is indicated by the trailing / on $uri/.)

The folder about/ matched, so nginx will then look for a file matching any of the names specified in the index directive. However, using an index file causes an internal redirect (quoted from the nginx docs), which is where your trailing / comes from.

For what it's worth, I see the exact same behavior on my nginx install, so it's not (just) your config.

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