laravel访问路由出现404,解决办法
程序员文章站
2022-05-29 21:35:54
...
问题描述
除了首页,访问其他路由页面都出现404
解决办法
- 在location里面加上 try_files uri/ /index.php?$query_string;
- 如果配置文件中存在 try_files uri/ =404;需要将它注释掉或者删掉,否则会报错
我的nginx配置文件如下
server {
listen 80;
server_name www.51growup.com;
root /data/wwwroot/default/51growup/public/;
index index.html index.php index.htm;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.2-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
推荐阅读