Starting on October 19, 2021, we will enable single-sign-on for our Plesk Support Center to provide a seamless login/account experience. This implies that you’ll be able to use a single account across any of our web-facing properties.
To be prepared for this change and to avoid the need to register during your next ticket submission after the change, we encourage you to create an account here before October 19 using the same email address as your current Zendesk login (support account). It’s essential that you use the same email address on our support center to ensure that your tickets stay attached to the same account. You will continue to use ZenDesk authentication until we switch over to single-sign-on on October 19th.

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

Follow

Comments

56 comments

  • Avatar
    Ivan Postnikov

    @Ion Iacob

    Hi!

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

    1
    Comment actions Permalink
  • Avatar
    Arda Oğul Üçpınar

    Hell! You saved my day man! Thanks.

    1
    Comment actions Permalink
  • 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;
    }

    1
    Comment actions Permalink
  • Hi Andy Little,

    If you turn off Proxy mode, then the webserver won't use .htaccess rewrite rules. Then, yes, you should use the resolution from this article.

    1
    Comment actions Permalink
  • 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 ....

    1
    Comment actions Permalink
  • Hi Andy Little,

    Article is updated. Thanks :)

    1
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @Ion Iacob

    Hello!

    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.

    1
    Comment actions Permalink
  • Hi Andy Little,

    The Wordpress Toolkit extension now adds automatically some configuration on Nginx in order to make work the permalinks.

    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
    JackLinkers (Edited )

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

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

    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
    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.

    0
    Comment actions Permalink
  • Avatar
    Malcolm.Allen

    After trying many different "fixes" found on the web, this one actually worked. Thank you!!

    0
    Comment actions Permalink
  • 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.

    0
    Comment actions Permalink
  • 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
    0
    Comment actions Permalink
  • Avatar
    Lev Iurev

    @Tadashi  this menu is available only for Plesk admin

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    Hi Francisco Roman Garcia Rodriguez,

    That would make sense, however, my Magento sites all work with FPM served by Nginx and they use htaccess rewrite rules.

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Allen

    Here is the entire htaccess file

     

    [content of the htaccess file has been removed]

    0
    Comment actions Permalink
  • 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.

    0
    Comment actions Permalink
  • Avatar
    Oleg Burca

    Plesk team,

    Can you please add instructions for Obsidian also?

    Thank you!

    0
    Comment actions Permalink
  • Avatar
    Jeff Carter

    My testing shows that #2 is correct.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov (Edited )

    @Marcos

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

    Please, check these articles: 1, 2

    0
    Comment actions Permalink
  • 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, mydomain.com/?about. How do I get rid of the "?" before my page name in the URL?

    0
    Comment actions Permalink
  • Avatar
    Koray Snoray

    this works, but the mail autosdiscovery is broken after this.. 

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    Thanks Francisco Roman Garcia Rodriguez,

    Actually, it's all our Magento sites (M1 and M2) and all our WordPress sites. They all work with FPM served with Nginx and I've not had to make any special accommodations. Literally all I did was switch to "FPM served by Nginx" in the PHP settings and that's it. They all still work. No issues with redirects as others have described. 

    From what I've read, this shouldn't be the case. 

    In the Apache and Nginx settings, Nginx is set in proxy mode. I'm not sure if this is why, but nowhere else does anyone mentioned disabling this before getting the 404 errors.

    Thanks again

    0
    Comment actions Permalink
  • 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
    Konstantin Annikov

    @Jeff

    Yes, you are right here. 

    Thank you for the input. 

    0
    Comment actions Permalink
  • Hi Andy Little,

    I could test this behavior in a test environment, and what I could deduct from it is that it's something implemented in magento2-core, as this only happens with Magento, not with a regular PHP test page.

    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