我使用Ubuntu安裝了Nginx的laravel。除了一個問題,一切都很好。當用戶使用404錯誤頁面插入像domain.com/user/whatever.php nginx響應之類的任何url時,而不是顯示laravel 404頁面。url whatever.php nginx 404錯誤代替laravel 404錯誤
我在nginx配置中缺少什麼?
我nginx的配置文件:
server {
listen 80;
server_name ip domainFotcom wwwDotdomainDotcom;
return 301 https://domainDotcom$request_uri;
}
server {
listen 443 ssl http2;
server_name ip wwwDotdomainDotcom;
return 301 $scheme://domainDotcom$request_uri;
}
# Default server configuration
#
server {
#listen 80 default_server;
#server_name ip domainDotcom wwwDotdomainDotcom;
#listen [::]:80 default_server;
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
root /var/www/domain/public;
# Add indexDotphp to the list if you are using PHP
index indexDotphp indexDothtml indexDothtm indexDotnginx-debianDOthtml;
server_name domainDotcom;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri $uri/ /indexDotphp?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
}
,你可以在我的文件中的配置代碼中看到我有 位置/ { try_files $ URI $ URI//index.php?$query_string ; } 設置。我的laravel應用程序中也有一個404頁面。 –
404頁面的完整文件路徑是什麼? – haakym
它在views/errors/404.blade.php文件中對於所有路由都能正常工作,除非路由以whatevername.php結尾 –