"未指定输入文件。"在NGINX中遇到错误而不是404错误

时间:2017-03-23 04:49:22

标签: php nginx

我面临同样的可怕"没有指定输入文件。" NGINX中的消息。我想要实现的目标的简要说明如下所示。

  1. 以" .php"结尾的任何现有网址扩展名应显示为404错误[working]
  2. 任何现有的网址没有" .php" extension将执行文件[working]
  3. 任何不存在的网址都应该抛出404错误[无法正常工作]。在这种情况下,NGINX抛出的错误是"没有指定输入文件。"
  4. 我已访问并尝试实施位于Nginx + php fastcgi showing "No input file specified." instead of 404的解决方案,但这并没有解决我的问题。

    我真的不确定如何在第3点渲染404页面。

    / etc / nginx / sites-enabled / default文件的内容在下面给出

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html/example.com;
        index index.php index.html index.htm;
        server_name example.com;
        error_page 404 /error/custom_404;
    
        location / {
            try_files $uri $uri/  @missing;
        }
    
        location ~ (\.php$|myadmin) {
        return 404;
        }
    
        location @missing {
                fastcgi_param SCRIPT_FILENAME "$document_root$uri.php";
                fastcgi_param PATH_TRANSLATED "$document_root$uri.php";
                fastcgi_param QUERY_STRING    $args;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
    
        location ~ /\.ht {
            deny all;
        }
    }
    

    请记住,我只是一个初学者,而不是专家。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

在将location @missing块传递给php-fpm之前,您的location @missing { if (!-f $document_root$uri.php) { return 404; } ... } 块无法验证文件是否存在。添加文件存在检查:

if

有关详情,请参阅this document<div id="container"> <div id="alljobs"> <div id="posts"> //wp loop #1 //all jobs will be here from all cats; post title etc. </div><!--Posts --> <div id="alljobspagi"> //the pagination for all jobs </div><!--alljobspagi --> </div><!--alljobs --> <div id="alljobspg"> <div id="posts"> //wp loop #2 //all jobs will be here from pg cats; post title etc. </div><!--Posts --> <div id="alljobspgpagi"> //the pagination for all jobs </div><!--alljobspgpagi --> </div><!--alljobspg --> </div><!-- The container --> 使用this caution

相关问题