nginx的location配置没生效?

image.png
然后访问
http://127.0.0.1/xxxx 结果404,
然后看一下error日志,为什么去查找nginx-1.16.1/html/xxxx文件,不是nginx-1.16.1/xxxx/index.html吗
image.png

阅读 5k
2 个回答

因为/xxxx/xxxx/是不同的location。你得访问/xxxx/才会命中你下面那个location,否则你得改成location /xxxx而不是location /xxxx/

改用location /xxxx的时候,访问/xxxx nginx会给你返回一个301,重定向到/xxxx/

你应该详细阅读下nginx的location指令的说明: http://nginx.org/en/docs/http...

如果想知道nginx是如何命中location的,可以使用nginx-debug命令启动nginx,然后查看error log

缓存问题,,重新reload后,生效了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题