• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Resolved After enabling NGINX, all posts in WordPress blogs in sub-directories are giving 404 Page Not Found

meymigrou

New Pleskian
After I enabled NGINX from Plesk (Web Pro) all my posts in my main and sub-directory blogs give 404 Page Not Found error.

I placed the following code in my "Additional NGINX Directives" in Plesk to fix all the URLS, but it only fixed the main site (example.com) while the sub-directory blogs (example.com/tech/, example.com/mag/ and example.com/dispatch/) are still giving 404 error.

Code:
# Wordpress Permalinks

if (!-e $request_filename) {

    rewrite ^(.+)$ /index.php?q=$1 last;
}

After that, I removed the code and placed the following one:

Code:
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;

}

I found this code in one of the official Plesk pages, and it says:

If a WordPress installation is located in a subdirectory (for example, "httpdocs/sub-dir") or this is a WordPress multisite network based on subdirectories, add the /sub-dir/ before /index.php?$1 so it will look like this: rewrite ^/(.*)$ /sub-dir/index.php?$1;

Note: For WordPress multisite network based on subfolder, add the above rule for each subdirectory.

As of now I got this (which doesn't work):

Code:
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;

rewrite ^/(.*)$ /tech/index.php?$1;

rewrite ^/(.*)$ /mag/index.php?$1;

rewrite ^/(.*)$ /dispatch/index.php?$1;

}

Any help will be much appreciated!

P.S. The main website works like a charm. In example.com/tech/ and /mag/ and /dispatch/ while the homepages are fine, the posts are giving me a 404 page error. I also updated the permalinks in WordPress and it didn't help.
 
Could anyone please take a look and provide me with the right code for Additional NGINX Directives? I'm taking for a website with thousands of visitors each month so it's super important to fix the issue. Any help will be much appreciated!
 
Good day,

have you somehow managed to solve it?

I have a similar problem. I have a wordpress multisite subdirectory and when switching php to NGINX everything works except the administration of plugins in subpages. I tried almost everything I read on the internet, but I couldn't solve it.
 
Good day,

have you somehow managed to solve it?

I have a similar problem. I have a wordpress multisite subdirectory and when switching php to NGINX everything works except the administration of plugins in subpages. I tried almost everything I read on the internet, but I couldn't solve it.

Sorry for the big delay! I've placed the following code in my main's website .htaccess file and all subdirectories started working as expected.

Code:
RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]

RewriteRule . index.php [L]

Solution credits goes to WPMUDEV.
 
Yes but that solution will work if you just want to use Apache as webserver and nginx as a simple proxy. It does not fix the issue for when you have proxy mode disabled and NGINX is the only one serving the content.
 
Sorry for the big delay! I've placed the following code in my main's website .htaccess file and all subdirectories started working as expected.

Code:
RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]

RewriteRule . index.php [L]

Solution credits goes to WPMUDEV.
 
I am using Nginx as a proxy behind Apache
I have setup my network to use sub-folders NOT sub-domains
I placed the above code into my .htaccess file and the sub-site URLS works on the front end. However, when I try to access the admin URL for a sub-site it throws a 404 error.

More guidance is required, please!
 
Back
Top