<form action ='connect.php',提交后会导致404错误

时间:2019-12-02 22:26:11

标签: php nginx

提交HTML表单时,使用“ form action ='connect.php'”,Nginx会引发404错误。 /var/log/nginx/error.logs指示nginx正在尝试在/ usr / share / nginx中查找文件,而不是/ var / www / html /的已定义文档根目录?为什么在错误的位置寻找它?以前从未遇到过这个奇怪的令人困扰的问题:

Nginx日志:

2019/12/02 22:12:12 [error] 10675#10675: *7 open() "/usr/share/nginx/html/php/connect.php" failed (2: No such file or directory), client: 192.168.1.1, server: example.com, request: "POST /php/connect.php HTTP/1.1", host: "example.com", referrer: "https://example.com/"
2019/12/02 22:12:15 [error] 10675#10675: *7 open() "/usr/share/nginx/html/php/connect.php" failed (2: No such file or directory), client: 192.168.1.1, server: example.com, request: "POST /php/connect.php HTTP/1.1", host: "example.com", referrer: "https://example.com/"

Nginx虚拟主机配置:

server_name     example.com www.example.com;
        location /{
                root /var/www/html/example.com/;
                index index.html;
                }

        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

        location /php {
            include fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param HTTPS on;
            #Avoid sending the security headers twice
            fastcgi_param modHeadersAvailable true;
            fastcgi_param front_controller_active true;
            fastcgi_intercept_errors on;
            fastcgi_request_buffering off;

在任何其他虚拟主机中都没有对/ usr / share / nginx的引用,也没有默认的nginx.conf文件。

我不知道为什么nginx会将请求路由到虚构的根。

0 个答案:

没有答案