• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Plesk wordpress 404 Not Found nginx

dolomats

New Pleskian
Hello,

i went to server setting and checked manage php with nginx then start getting 404 Not Found nginx.

It was clear that it s a problem with the wordpress permanent links so i went in wordpress back-end and switched to default links then it start working but when i switched to permanent link againi got the
previous error again

I searched for a while on internet and i found an awsome post here that helped me esolve the problém
http://www.curvve.com/blog/servers/...nginx-and-php-fpm-not-rewrite-wordpress-urls/

So the problem that i have is that i added this piece of code manually in :
ok.png
/var/www/vhosts/system/domaine.com/conf/nginx.conf

Since it s mentioned above

#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

So i wanna know in witch file i should edit the code to dont lose it.

Thank you
 
UPDATE

Tired of searching on the web without results so I end up here asking for help.

I am using Plesk to manage my server I activated PHP-FPM for Nginx and wanted start Processing PHP by Nginx so I set up these options (picture below):

IMAGE :
U8Ul0a


The Index page is working well because I add it in the setting as you can see on the image The probléme is the Permanent link any link i click on i get 404 Not Found Nginx When I turn off Wordpress permalinks All work fine and when I switch back only the home page work.

Any help pls !
 
Well ty guy s for help by searching more in the forum and other external forum i was able find solution

Here steps how to add custom include in nginx virtual host config:


mkdir /usr/local/psa/admin/conf/templates/custom/domain


cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/


and edit the location code already in with this code below

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


/usr/local/psa/admin/bin/httpdmng --reconfigure-all # to apply new configuration for all domains

hope that will help peoples

Thanks
 
This is the absolute WRONG way to add additional rewrites for a domain.

Each domain has specific webserver settings and additional options which you should use, if you would like to add additional rewrite rules for a domain and it's content. The general modification of the templates might result in failures for other domains on the server and it's content. :(
 
Thanks for the Reply

Until now it s working fine no problem maybe becoz i m using same configuration for both websites but can u explain me your ways or the right way step by step !

Greeting
 
Hi dolomats,

please be so kind to read the Plesk documentation about "Additional directives" ... it is very good explained there and doesn't have to commented to be more clear. The Plesk online documentations ( links are already mentioned in a previous post ) have as well a SEARCH form, where you may put the word "Additional" or the word "Directives" to find the depending parts in the documentation.
 
Hi,
i wanna know what is the exact mystake the code that i inserted ?

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

Or the place where i add it :

/usr/local/psa/admin/conf/templates/custom/domain

and about that documentation link it s soo General u cant give me direct link to the spécifique topic.

Thank you
 
Hi dolomats,

the custom templates are used to override the system configuration templates in order to adjust or modify the templates to your very special needs and domain directives are used to define domain specific definitions. Using the way that you use, you will never will profit again from patches, updates/upgrades provided by Plesk for the custom templates, because the default templates may be patched/updated/upgraded, but never will be used, if they are custom templates.

Another reason, why the way is absolut incorrect is the equivalent htaccess - usage with apache - you would never define global htaccess - directives for all domains, because this may break the web - content code of another domain - you would use the specific apache - and nginx additional directives for each domain.

And last, but not least, you use a global rewrite rule, without thinking about the security wholes, you are opening with it. If you have "try_files $uri $uri/ /index.php?$args;" defined for upload directories as well, then any malicious code might be added and a index.php - file turn into a spambot, or even worse commands can be performed.

... but it's YOUR server... enjoy the Christmas holidays and maybe you will consider to think over your rash action. :)
 
Hi,

Thanks for answer. What you saying seems serious issue and i dont wanna stick with that in my server but this is the only way i found to resolve my initial probléme "Plesk wordpress 404 Not Found nginx".

I think maybe u understanded well my probléme so if u can give me an alternative solution will be greatfull (exept reading all plesk documentatons)

becauz i dont really like to read specially if it s many many words....

Thanks
 
wordpress nginx directive for wordpress
# Wordpress permalinks
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}

if you use nginx
 
Hello guy's I m pleased to tell you that i found better solution to fix this 404 Nginx error.

You just need to download this extension : htaccess to nginx

And go to your domaine -> Web Server Settings -> click on Show .htaccess converter -> Copy what u already have on your .htaccess in your ftp root -> then click
convert to nginx.

So it will convert it and past it in the Additional nginx directives field then save it and "Ta Da !!!!!"

It s gonna be working Inchaalah without any security issue. our freind UFHH01 know what i m talking about.http://talk.plesk.com/members/ufhh01.148826/
 
For anybody with similar issues, to change your sever globally
Code:
mkdir -p /opt/psa/admin/conf/templates/custom/domain/
cp /opt/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /opt/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php

Then edit that file and change at the bottom:
PHP:
location ~ /$ {
        <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
    }
to
PHP:
location ~ /$ {
        <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
        try_files $uri $uri/ /index.php?$args;
    }

Then run
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all


I wanted it global as I run wordpress on all my sites and it worked like a charm for me!
 
For anybody with similar issues, to change your sever globally
Code:
mkdir -p /opt/psa/admin/conf/templates/custom/domain/
cp /opt/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /opt/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php

Then edit that file and change at the bottom:
PHP:
location ~ /$ {
        <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
    }
to
PHP:
location ~ /$ {
        <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
        try_files $uri $uri/ /index.php?$args;
    }

Then run



I wanted it global as I run wordpress on all my sites and it worked like a charm for me!

yes its working like charm but getting server response time issues and please any buddy knows there is any way to just word-press get that below settings rather than globle ?

i am using plesk web admin edition 12.5.30
 
Back
Top