After switching a WordPress website to FPM served by nginx in Plesk, it fails to load with "404 Not Found" on all pages except start page




  • Avatar
    Tadashi Spade

    i am new to Plesk.
    my Plesk does not showing me this menu Plesk > Domains > > 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.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 "" and there should be a second wordpress installation in "", how can I add the rule to this domain while having "" still working?

    When I add the rule for ../test to the nginx-settings for 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/ ;
    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:

  • Avatar
    Jonas Klinker (Edited )

    @Denis Bykov

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

    No matter, I got an error when setting on domain ->  Additional nginx directives field in Plesk at Domains > > 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
    Unknown User

    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.

  • Avatar
    Boun Vilailath (Edited )

    My urls work fine when I choose plain permalinks where it shows my page url by ID. But this url structure is not desirable.

    This problem is happening to me when I install WordPress on a subdomain. Why is it that all my subpage URLs have to have a "?" in front for it to work after I insert ngix code. For example, How do I get rid of the "?" before my page name in the URL?

  • Avatar
    Artyom Volov

    Hello @Boun Vilailath,

    This is expected the behavior of default Plain permalinks in WordPress.

    If it is required that Permalinks display ID without questions mark, I suggest using Custom Structure for Permalinks.

    To do that:
    1. WordPress Dashboard > Settings > Permalinks.
    2. Select Custom Structure.
    3. Select "/%post_id%/".
    4. Click Save Changes.
    where you can select "/%post_id%/".

    In this case, URL will be displayed without the mark:

  • Avatar
    JackLinkers (Edited )

    rewrite ^/(.*)$ /sub-directory/index.php?$1;

    rewrites WordPress URL's in subdirectory, but now throws 404 errors on static files.

  • Avatar
    Alexandr Redikultsev

    Hi @JackLinkers,

    You should use try_files or if if (!-e $request_filename) in order to process static files without rewriting anything to avoid getting 404 errors.

  • Avatar

    This is the HTACCESS config.

    [content of the apache configuration file has been removed]

  • Avatar

    Here is the entire htaccess file


    [content of the htaccess file has been removed]

  • Avatar
    Konstantin Annikov (Edited )

    Could you please clarify your question? Am I right that htaccess files are not working for the website?
    If so, please check that php is being processed by Apache under Plesk > Domains > > PHP Settings .
    In case the handler has been switched to 'FPM served by nginx', htaccess files are ignored. This is how nginx works.

  • Avatar
    Arda Oğul Üçpınar

    Hell! You saved my day man! Thanks.

Please sign in to leave a comment.

Have more questions? Submit a request