A WordPress website on a Plesk server shows "404 Not Found" on all pages except index.php, when running on FPM by nginx




  • Avatar
    Tadashi Spade

    i am new to Plesk.
    my Plesk does not showing me this menu Plesk > Domains > example.com > Apache & nginx Settings 
    please help ....

  • Avatar
    Lev Iurev

    @Tadashi  this menu is available only for Plesk admin

  • Avatar
    Jeff Carter

    My nginx config analysis warns that the prescribed replacement:

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

    Does not have an ideal regex pattern.....

    "Regex location has no regex pattern
    Regex location has a valid modifier, but does not have a regex pattern.
    Performance-wise it is more efficient to configure exact or prefix matching for locations that do not require regex matching. It is also less prone to errors. Please refer to the documentation describing location directive to learn more."

    "Regex location has no anchors in regex pattern
    Regex location has a regex pattern without ^ or $. This is a configuration style that is prone to errors. It may also lead to a situation when requests partially matching the regex pattern are incorrectly routed to this location.
    Always use ^ or $ achor in a regex pattern."

    Given this advice, should that location directive be modified?




  • Avatar
    Robert Asilbekov

    @Jeff  As far as I understand analyzer does not like ~ in location. According to nginx docs "...the “~” modifier (for case-sensitive matching). To find location matching a given request, nginx first checks locations defined using the prefix strings (prefix locations)."

    You may remove "~" it should not affect performance. As for other options, I see no problems. Moreover, the same sample is provided by Nginx and WordPress. However, it would be great if you may suggest a better option to build an ideal regex.


  • Avatar
    Jeff Carter

    Yes, my question really boils down to which new configuration the article should advise:

    1. location / {

    (Which essentially removes the regex)


    2. location ~ /$ {

    (Which correctly anchors the general regex pattern)

    It does seem that the WordPress Codex recommends #1.  Is there agreement then?

  • Avatar
    Jeff Carter

    My testing shows that #2 is correct.

  • Avatar
    Konstantin Annikov


    Yes, you are right here. 

    Thank you for the input. 

  • Avatar
    Jonas Klinker

    How can I add the rule for each subdirectory for wordpress multiside?

    i.e.: domain is "example.de" and there should be a second wordpress installation in "example.de/test", how can I add the rule to this domain while having "example.de" still working?

    When I add the rule for ../test to the nginx-settings for example.de like:

    if ($test = PC) {
    rewrite ^/(.*)$ /index.php?$1;

    rewrite ^/(.*)$ /test/index.php?$1;


    It will work on subdomain, but the main domain isnt working anymore..

    Thanks for your help!

  • Avatar
    Ion Iacob

    My sites with wordpress give error 500. Where and how can we see the error? Only when I delete all the themes of the wordpress allows me to access wp-login.php, but when installing a theme the site breaks again.

  • Avatar
    Ivan Postnikov

    @Ion Iacob


    There is a possibility that some plugin or theme contains error and provokes such issue.
    Here is the article for troubleshooting error 500: [HUB] error 500.

    In case the investigation from our side is required, contact Plesk Technical Support.

  • Avatar
    Ion Iacob

    I'm running the compando # ls /var/log/ and I can not find the apache folder.
    I have 2 subscriptions in plesk. One works with wordpress perfectly. The other one has stopped working, but if I install wordpress again it works for a few hours, then again it gives 500 error to the web page.

  • Avatar
    Ivan Postnikov

    @Ion Iacob


    In case your OS is CentOS, Apache logs are at /var/log/httpd.
    Please, consider contacting Plesk Technical Support.

  • Avatar
    Denis Bykov (Edited )

    @Jonas Klinker
    According to WordPress blog page, correct Nginx rewrite rules for a subdirectory multisite setup are following:

    location ~ ^(/[^/]+/)?files/(.+) {
    try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
    access_log off; log_not_found off; expires max;

    location ^~ /blogs.dir {
    alias /var/www/example.com/htdocs/wp-content/blogs.dir ;
    access_log off; log_not_found off; expires max;

    if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
    rewrite ^(/[^/]+)?(/.*\.php) $2 last;

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

    location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass php;

    Refer to the following page for more information: https://codex.wordpress.org/Nginx

  • Avatar
    Jonas Klinker (Edited )

    @Denis Bykov

    Thanks for your help! I have to change "example.com" and "blog.dir", right?

    No matter, I got an error when setting on domain ->  Additional nginx directives field in Plesk at Domains > example.com > Apache & nginx Settings

    nginx: [warn] duplicate MIME type "text/html" in /var/www/vhosts/system/DOMAIN1/conf/vhost_nginx.conf:15 nginx: [warn] duplicate MIME type "text/html" in /var/www/vhosts/system/DOMAIN2/conf/vhost_nginx.conf:15 nginx: [warn] duplicate MIME type "text/html" in /var/www/vhosts/system/DOMAIN2/conf/vhost_nginx.conf:15 nginx: [emerg] no port in upstream "php" in /var/www/vhosts/system/DOMAIN2/conf/vhost_nginx.conf:25 nginx: configuration file /etc/nginx/nginx.conf test failed
  • Avatar
    Alexander Tsmokalyuk


    Please make sure you haven't specified "text/html" type in Additional nginx directives. This type is included by default and should not be specified explicitly.

  • Avatar
    Marcos Paulino Chahin

    On both a new and old plesk onyx server using web host, we get this:


    Error: phpinimng failed: Unable to update the config file for 'fpm' service due to syntax errors.


    When we add the directives to a single website.  Any ideas why?

  • Avatar
    Ivan Postnikov (Edited )


    Generally, this error means that PHP handler configuration contains a syntax error.

    Please, check these articles: 1, 2

  • Avatar
    Marcin Horecki

    This directive breaks the wordpress WP Rocket cache plugin. Caching doesn't work for all pages except homepage.


    If I use another directive below - WP rocket works correctly:

    if (!-e $request_filename){
    rewrite ^(.*)$ /index.php break;

  • Avatar
    Ivan Postnikov

    @Marcin, thank you for letting us know about the issue.

    To resolve the issue with Nginx configuration compatibility with WP Rocket, consider contacting WP Rocket Support.

  • Avatar
    Peter Luit

    Well, since I am not the admin on the highest level in Plesk, I cannot modify any settings to make a WordPres site run under Nginx. Is there any other way to do this?

  • Avatar
    Ivan Postnikov

    Hello @Peter, in such case you need to contact Plesk administrator and request performing the steps from this article.

    Thank you for understanding.

Please sign in to leave a comment.

Have more questions? Submit a request