• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Vhosts nginx configuration misconfiguration for wordpress? (add index.html to pathname)

blueberry

Basic Pleskian
Hi,
After installing wordpress and disabling Apache, I have found that while URLs are accessible it returns an error in the Nginx error logs.
For some reasons, the code add the index file at the end of the URI. Here is a log example returned after visiting
Code:
https://inadoo.com/cest-un-nombre/
// As you can see Nginx look for the URI and add the first index file at the end of it.

1602530472336.png
The system also return a proper 200, that's why we don't see it. In other words, everytime I access a URL on a nginx only installation, I get a 200 and also an error recorded in the Nginx error log. I guess the problem is located at /etc/nginx/plesk.conf.d/vhosts/xxxx.com.conf where the nginx directives are located.

I have not added anything to the Nginx additional directives.
 
Last edited:
thank you

so I added
1602562317856.png
then I called the URL
1602562527225.png
And unfortunately, after visiting the logs, the problem is still there. and by the way, it happens with all my domains using nginx on my server.
1602562484235.png

Here is how to repeat the problem:
1. Install wordpress on a domain using Plesk
2. Disable Apache by unchecking Proxy mode in the category "Apache & nginx settings.
3. In wordpress administration, settinbgs>permalinks : set to permalink /sample-post/
3. visit a URL of the website
4. Checks the logs, for a visited URL you should see two entry, 1 file not found error and one 200 for the access
 
Last edited:
Problem was solved by adding

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

At the end of nginx additional settings
 
Last edited:
If you want to add other regex directives with it, you must add the following:
Code:
location / {

#add location regex here



location ~* "^/(.+)(!wp-admin|wp-login|wp-content|wp-includes)/$" {
        if (!-e $request_filename) {
            rewrite ^/(.+)/$ /index.php last;
        }
    }


}
 
Back
Top