【问题标题】:stuck on nginx location directive卡在 nginx 位置指令上
【发布时间】:2013-08-07 09:05:05
【问题描述】:

我正在使用 Windows 并使用 Winginx,修改 conf 文件夹下的 nginx.conf 文件。我已将监听端口的服务器块更改如下:

server{
 listen 127.0.0.1:80;
 log_not_found off;
 charset utf-8;

 access_log logs/access.log main;

 location /images/ {
  root home/localhost/public_html;
  index index.php index.html;
 }
}

images 文件夹在 winginx 的 home 文件夹下,通过 hostseditor 添加为域。但是,当我使用 URL http://images 时,出现 404 错误。

如果位置指令更改为:

location / {
}

然后一切正常。除非我匹配“/”,否则任何正则表达式都不起作用。我已阅读位置指令,但找不到任何相关原因。如果有人能指出错误,那将是很大的帮助。谢谢。

【问题讨论】:

    标签: nginx webserver httpserver winginx


    【解决方案1】:

    原因是 location 指令匹配 URI(更准确地说是 Request-URI 的绝对路径),而不是 Host。

    当您使用http://images 时,您的浏览器会发送如下请求:

    GET / HTTP/1.1
    Host: images
    

    请注意,请求 URI 是 /

    【讨论】:

      猜你喜欢
      • 2012-11-09
      • 1970-01-01
      • 2012-04-22
      • 1970-01-01
      • 2020-10-17
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      相关资源
      最近更新 更多