Wordpress Nginx try_文件赢得';t从index.php触发响应

Wordpress Nginx try_文件赢得';t从index.php触发响应,wordpress,nginx,robots.txt,php,sitemap.xml,Wordpress,Nginx,Robots.txt,Php,Sitemap.xml,在我的例子index.php中,try_文件似乎没有将对不存在的文件的请求传递到最后指定的值,这是一个问题。我正在使用Wordpress,我使用的XML站点地图生成器插件创建虚拟XML文件和一个由Wordpress处理的虚拟robots.txt。不幸的是,try_文件似乎没有将这些文件的请求传递给Wordpress 以下是我的服务器配置: server { ## Web domain server_name christiaanconover.com;

在我的例子index.php中,try_文件似乎没有将对不存在的文件的请求传递到最后指定的值,这是一个问题。我正在使用Wordpress,我使用的XML站点地图生成器插件创建虚拟XML文件和一个由Wordpress处理的虚拟robots.txt。不幸的是,try_文件似乎没有将这些文件的请求传递给Wordpress

以下是我的服务器配置:

server {
        ## Web domain
        server_name christiaanconover.com;
        ## Site root
        root /var/www/christiaanconover.com;
        ## Index
        index index.php index.htm;

        ## Common Wordpress configuration
        include wp.conf;

        ## Include PHP configuration
        include php.conf;

        ## Gzip Compression
        include gzip.conf;

        ## Include W3TC configuration
        include /var/www/w3tc/christiaanconover.com;
}
我在这台服务器上运行多个单独的Wordpress站点,因此为了节省时间,我创建了一个文件wp.conf,其中包含Wordpress的所有常用配置元素。以下是wp.conf的内容:

location / {
        ## Prevent PHP files from being served as static assets, and fall back to index.php if file does not exist
        try_files $uri $uri/ /index.php?$args;

        ## If a file exists, serve it directly
        if (-f $request_filename) {
                break;
        }

        ## Wordpress Rewrite
        if (!-e $request_filename) {
                rewrite ^ /index.php last;
        }
}

其他一切都很好地工作,但try_文件的安排似乎并没有正常进行。有什么想法吗?

您遇到了中描述的问题之一

您在
wp.conf
中指定的
ifs
是不需要的,您的
try\u文件已经覆盖了它们,因此您可以删除它们,从而产生:

location / {try_files $uri $uri/ /index.php$is_args$args;}
这将:

  • 检查是否存在与$uri(相对于root指令指定的位置)匹配的文件
  • 如果没有,请检查目录匹配是否存在
  • 否则重定向到
    /index.php$is_args$args
  • 当设置时,其中的计算结果为