NGinx / PHP 404 从主网站重定向时未找到
NGinx / PHP 404 Not Found when redirecting away from main website
我得到了我的主要网站 运行,但是点击网站上的任何按钮都会导致 404 错误。按钮显示它正在 public 目录中寻找实际页面(例如 /signin 或 /signup),但只有 index.php。知道为什么吗?我在下面粘贴了 nginx cfg 和错误日志。
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
root /root/var/www/myforum/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name www.example.com;
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;
}
}
单击我网站上的“登录”按钮时的错误日志:
2021/12/10 01:54:34 [error] 53165#53165: *333 open() "/root/var/www/myforum/public/signin" failed (2: No such file or directory), client: 1xx.xxx.xx.xxx, server: www.example.com, request: "GET /signin HTTP/1.1", host: "xx.xxx.xxx.1xx", referrer: "http://xx.xxx.xxx.1xx/"
问题是第二个 /root/ 以及一个缺失
location / {
try_files $uri $uri/ /index.php?$query_string;
}
我得到了我的主要网站 运行,但是点击网站上的任何按钮都会导致 404 错误。按钮显示它正在 public 目录中寻找实际页面(例如 /signin 或 /signup),但只有 index.php。知道为什么吗?我在下面粘贴了 nginx cfg 和错误日志。
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
root /root/var/www/myforum/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name www.example.com;
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;
}
}
单击我网站上的“登录”按钮时的错误日志:
2021/12/10 01:54:34 [error] 53165#53165: *333 open() "/root/var/www/myforum/public/signin" failed (2: No such file or directory), client: 1xx.xxx.xx.xxx, server: www.example.com, request: "GET /signin HTTP/1.1", host: "xx.xxx.xxx.1xx", referrer: "http://xx.xxx.xxx.1xx/"
问题是第二个 /root/ 以及一个缺失
location / {
try_files $uri $uri/ /index.php?$query_string;
}