Symptoms
-
Website pages based on WordPress show below error on all pages except the main one:
404 Not Found
when:
-
FPM application served by nginx is set in Domains > example.com > PHP Settings
- Proxy Mode is enabled at Domains > example.com > Apache & nginx Settings.
- Non Plain is set in WordPress Dashboard > Settings > Permalinks type
-
FPM application served by nginx is set in Domains > example.com > PHP Settings
-
WordPress REST API point (wp-api) shows 404 error. It can be checked by accessing
http://example.com/wp-json/wp/v2/posts
Cause
WordPress detects that php files are handled by Nginx and doesn't generate .htaccess
file. At the same time permalinks continues to be served by Apache when Proxy mode is enabled.
Since .htaccess
with Apache rewrite rules doesn't exist WordPress shows 404 error for pages.
The behavior that PHP continues to be served by Apache when Proxy mode is enabled is considered a bug with the ID #PPPM-11234.
Resolution
One of below workarounds can be used:
Switch PHP handler to "PHP-FPM served by Apache" (preferred workaround)
- Go to Domains > example.com > PHP Settings
- Set PHP FPM application served by Apache and click on OK
- Go to Domains > example.com > WordPress > Log in
- Go to Settings > Permalinks
- Click on Save Changes
Via Plesk GUI(using .htaccess
file)
-
Go to Domains > example.com > File Manager > httpdocs
-
Create the
.htaccess
with following content:# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress -
Click Save button
Via SSH(using .htaccess
file)
-
Create
/var/www/vhosts/example.com/httpdocs/.htaccess
with below content:# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Additional information
Website pages based on WordPress show "404 Not Found" when PHP-FPM by Apache is used