繁体   English   中英

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

[英]500 Server error with Plesk, NGINX, PHP-FPM when removing URL trailing slash

在运行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 /中的config 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文件,并将它们与存在该错误的域进行比较。 如果可能的话,我宁愿不走这条路。

谢谢!

您需要从位置块中删除$ ,因为此位置仅匹配以/结尾的URL,并且由于不需要正则表达式,因此您也可以删除~ ,因此最终结果是

location / {
    # your rewrites and try_files
}

奇怪,没有

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

我的永久链接出现404错误。 一切正常。 也许它将帮助某人。

对我来说,最终的工作代码如下:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM