代码之家  ›  专栏  ›  技术社区  ›  Scott Summers

删除URL尾部斜线时,Plesk、NGINX、PHP-FPM出现500服务器错误

  •  0
  • Scott Summers  · 技术社区  · 11 年前

    我在运行WordPress网站时遇到了一个非常奇怪的错误。

    WordPress已经打开了永久链接。当你从URL中删除尾部斜杠(/)时,会出现500服务器错误。例如: 网址:www.site.com/about/->工作正常。 网址:www.site.com/about->引发500服务器错误。

    错误日志显示以下内容:

    [Tue Sep 24 00:44:58 2013] [warn] [client 75.52.190.1] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
    [Tue Sep 24 00:44:58 2013] [error] [client 75.52.190.1] Premature end of script headers: index.php
    

    Wordpress调试日志处于活动状态,但不会生成任何错误或警告。

    其他需要注意的事项:

    • 该服务器有多个在Plesk 11.5下管理的域。
    • 只有一个域存在此问题。

    我将/var/www/system/domain/etc/中的配置vhost.conf文件与另一个没有此问题的wordpress域进行了比较。一切都是一样的。

    我还试着删除了所有的wordpress文件,并上传了一份全新的副本。即使有一个新的WordPress副本,没有插件、模板或其他任何东西,这个问题仍然会发生。

    我注意到的最后一件事。我的域特定vhost.conf包含以下信息:

    location ~ /$ {
     index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
     try_files $uri $uri/ /index.php?$args;
    }
    

    这似乎在寻找任何带有/的东西。我应该删除/或添加类似的块吗?我没有尝试的唯一原因是没有一个域受到这个问题的影响。我的下一步操作是下载所有域conf文件,并将它们与出现错误的域进行比较。如果可能的话,我宁愿不走那条路。

    谢谢

    3 回复  |  直到 11 年前
        1
  •  0
  •   Mohammad AbuShady ALoK VeRMa    11 年前

    您需要删除 $ 来自位置块,因为此位置仅与以 / ,并且由于您不需要regex,因此可以删除 ~ 也是,所以最终结果是

    location / {
        # your rewrites and try_files
    }
    
        2
  •  0
  •   Oleg Neumyvakin    11 年前

    奇怪,没有

    location ~ /$ {
        try_files $uri /wordpress/index.php?$args;
    }
    

    我有404个永久链接错误。有了它,一切都在运转。也许这会对某人有所帮助。

        3
  •  0
  •   Scott Summers    11 年前

    我的最终工作代码如下:

    location ~ / {
       index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
       try_files $uri $uri/ /index.php?$args;
    }