简体   繁体   中英

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

I'm running into an extremely bizarre error while running a WordPress site.

WordPress has permalinks turned on. The 500 server error occurs when you REMOVE the trailing slash (/) from the URL. For example: www.site.com/about/ -> works fine. www.site.com/about -> throws a 500 server error.

The error log show the following:

[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 debug log is active, but no errors or warnings are being generated.

Other points to note:

  • The server has multiple domains managed under Plesk 11.5.
  • Only one of the domains suffers from this issue.

I compared the config vhost.conf files located in /var/www/system/domain/etc/ to another wordpress domain that is not having this issue. Everything is identical.

I also tried removing all of the wordpress files and uploaded a completely fresh copy. The problem still occurs, even with a fresh copy of WordPress and no plugins, templates, or anything else.

One last item that I noticed. My domain specific vhost.conf has the following info:

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

That seems to be looking for anything with a /. Should I remove the / or add a similar block? The only reason I haven't tried is because none of the domains suffer from this issue. My next course of action would be to download all domain conf files and diff them against the domain with the error. I'd rather not go down that path if possible.

Thanks!

You need to remove the $ from the location block, because this location only matches URL's that end with a / , and since you won't need regex then you can remove ~ too, so the final result is

location / {
    # your rewrites and try_files
}

Strange, without

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

I've got 404 error for permalinks. And with it everything working. Maybe it will helps someone.

The final, working code for me is as follows:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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