【发布时间】:2017-03-29 20:44:40
【问题描述】:
这是我的服务器块:
server {
listen 80;
server_name localhost;
root /www/html;
index index.php;
location = / {
autoindex on;
index index.php;
try_files $uri $uri/ =404;
}
location ~*\.(css|js|gif|jpe?g|png)$ {
root /www/html/shared;
rewrite ^/releases(.*)$ $1 last;
expires 5m;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
现在,当我尝试访问“localhost/”时,这样做只会显示“403 Forbidden”错误。但是,如果我直接访问它——“localhost/index.php”,该页面工作得非常好。我无法为我的生活找出原因。 error.log 既没有给我任何有用的信息,也没有给我错误代码——只是页面被“禁止”了。 这是抛出的错误:
2017/03/29 14:37:35 [error] 11980#8840: *94 directory index of "C:/www/html/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
这是一个基于 Windows 的 nginx 服务器。
【问题讨论】:
-
尝试:
location / { ... },不带=。另外,删除autoindex on;。 -
试了一下,但它似乎没有改变输出。