我有以下 nginx 配置(在/etc/nginx/sites-available/default
)
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Run Code Online (Sandbox Code Playgroud)
我在损坏的 url 上收到 500 个服务器错误,而不是 404 错误。我该如何纠正?
这很可能是由于location /
块的工作方式造成的。请按以下方式更改...
location / {
try_files $uri $uri/ =404;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4729 次 |
最近记录: |