自定义PHP文件扩展名导致Wordpress安装错误

时间:2018-08-10 10:38:22

标签: php wordpress nginx centos7

最近,我更改了目录上的PHP文件扩展名,以便仅显示/而不显示.php,但是从那时起,我无法安装Wordpress,以更改我遵循的PHP文件扩展名StackOverflow的答案。

我当前的Nginx conf文件:

    location / {
            root   /var/www/public;
            #try_files $uri $uri/ = /404.html;
            if ($request_uri ~ ^/(.*)\.html$) {  return 302 /$1;  }
            try_files $uri $uri/ $uri.html $uri.php?$args;
            index  index.php index.html;
            add_header   Strict-Transport-Security "max-age=63072000; includeSubdomains" always;
    }

    error_page  404  /404.html;
    location = /404.html {
            root    /var/www/public;
            internal;
    }

    error_page  405  /405.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
            root   /var/www/public;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~* \.php$ {
            root           /var/www/public;
            #fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass php-fpm;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include  fastcgi_params;
            if ($request_uri ~ ^/([^?]*)\.php($|\?)) {  return 302 /$1?$args;      }
            try_files $uri = 404;
            fastcgi_split_path_info  ^(.+\.php)(/.+)$;
            fastcgi_param QUERY_STRING  $query_string;
            fastcgi_param REQUEST_METHOD  $request_method;
            fastcgi_param CONTENT_TYPE  $content_type;
            fastcgi_param CONTENT_LENGTH  $content_length;
            fastcgi_intercept_errors  on;
            fastcgi_ignore_client_abort  off;
            fastcgi_connect_timeout  60;
            fastcgi_send_timeout  180;
            fastcgi_read_timeout  180;
            fastcgi_buffers 256  16k;
            fastcgi_buffer_size  32k;
            fastcgi_temp_file_write_size  256k;

    } 

现在WP安装文件将数据发送到.php,但是随着数据被重定向并隐藏.php文件扩展名,因此出现错误,安装将无法进行。

所以我从Nginx配置文件中的location ~* \.php$ {删除了以下行,现在一切正常,但是我不想显示.php文件,所以有人可以建议,如何我安装了WordPress,但未显示.php

if ($request_uri ~ ^/(.*)\.html$) {  return 302 /$1;  }
        try_files $uri $uri/ $uri.html $uri.php?$args;
if ($request_uri ~ ^/([^?]*)\.php($|\?)) {  return 302 /$1?$args;  }

0 个答案:

没有答案