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

Follow

Comments

36 comments

  • Avatar
    Ivan Postnikov

    Hello @DoSieci,

    Your case requires the additional investigation.

    Please, submit a ticket to Plesk support, this will let us have a closer look at the issue.

     

    0
    Comment actions Permalink
  • Avatar
    Oleg Burca

    Plesk team,

    Can you please add instructions for Obsidian also?

    Thank you!

    0
    Comment actions Permalink
  • Avatar
    Julian Bonpland Mignaquy

    Hi Oleg Burca,
    I just run the solution on our test servers and the same applies for Onyx and Obsidian. Make sure that you are replacing the entire block:

    <?php if ($VAR->domain->physicalHosting->directoryIndex): ?>
    location ~ /$ {
    index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
    }
    <?php endif ?>

    with

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

     

    0
    Comment actions Permalink
  • Avatar
    Jorge Salazar

    Hi Kuzma Ivanov,

    I am tried to add this code to the file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php as explained in step 3 but in Plesk Obsidian the block of code that we need to replace is not exactly like the one you mentioned there.

     

    In my case the block of code I can see similar to the one mentioned here is this one (start at line:155 ):

    <?php if ($VAR->domain->physicalHosting->directoryIndex && !$VAR->domain->physicalHosting->proxySettings['nginxProxyMode']): ?>
    location ~ /$ {
    index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
    }
    <?php endif ?>

     

    Could you please check it and let us know what would be the bock of code to replace for Obsidian?

     

    Regards.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Jorge,

    The following config is to be replaced on Plesk Obsidian:

    <?php if ($VAR->domain->physicalHosting->directoryIndex && !$VAR->domain->physicalHosting->proxySettings['nginxProxyMode']): ?>
    location ~ /$ {
    index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
    }
    <?php endif ?>

    I've successfully tested it.

    The article will be updated.

    0
    Comment actions Permalink
  • Avatar
    Brian Lamb (Edited )

    Thank you @Denis Bykov

    This worked for me.  I run about 30 WP sites. What worked for me, was using the custom template.  I used the Plesk 17.8 settings above, under "For all existing and newly created websites in Plesk Onyx & Obsidian" . 

    e.g.

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

    This was the only way i could get the question mark out of the urls. For some sites the standard overrides, that you can add in "Additional nginx directives" would not work in some cases. 

    Note, to properly test that, you need to reset permalinks in some cases.  To do that, change them to Plain, CLICK SAVE, then Change them back, and click save.   Ignore the SEO warning when you do this. 

    Boun Vilailath, and all others having the question mark showing up still in their url, breaking pages, I wanted to say, i had the exact same issue, this resolved it for me, only after i removed the old settings that i had in the nginx/apache overrides.  so be sure to remove those after you add the new directives to a custom template.  

    e.g. the old settings are whats pointed out in the single site directive, which did not work for me on some sites.


    if (!-e $request_filename) {
    set $test P;
    }
    if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|internal-nginx-static-location)) {
    set $test "${test}C";
    }
    if ($test = PC) {
    rewrite ^/(.*)$ /index.php?$1;
    }

    Notice the rewrite rule there.  Thats whats adding the question mark.

    You need to use the full location block directive if your having the question mark still showing up, atleast for my version of Plesk (17.8). 

    Note, the title of the article is decieving, i never received a 404 not found, this because the home page url was still loading, the portion after the slash, e.g. /?about was not loading, due the question mark. So no 404 ever happened. Instead as mentioned, i just saw the home page.  SO they didnt 404, they just didnt work.  Hence, this article threw me off at first (weeks prior), in the sea of other help articles on this, i thought it was irrelavant, however in the end i found it was.  So it may help lots of other developers to update the title!!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request