我的Laravel 5网站重定向到404.它安装在一个文件夹中。
它正在使用Laravel 5.6和Nginx 1.12.1
重定向到404而不是我的项目。计划部署多个站点。
https://example.com/staging/project/ - >重定向到404而不是打开页面。
查找nginx配置
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
root /var/www/example;
index index.php index.html index.htm;
ssl_certificate "/etc/letsencrypt/live/example.com/fullchain.pem";
ssl_certificate_key "/etc/letsencrypt/live/example.com/privkey.pem";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
location ^~ /staging/project {
alias /var/www/example/staging/project/public;
index index.php
try_files $uri $uri/ /index.php$is_args$args @laravel1;
location ~ \.php {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
location @laravel1 {
rewrite /staging/project/(.*)$ /staging/project/index.php?/$1 last;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
答案 0 :(得分:0)
这里只有一件事我认为你需要改变,你几乎就在那里。
更改
root /var/www/example;
要
root /var/www/example/public;
每次更改xxx.conf文件时也始终重启Nginx。
Sudo service nginx restart