Articles in this section

WordPress websites on a Plesk server show "404 Not Found" when PHP-FPM by Nginx and Proxy Mode are used

kb: bug Plesk for Linux ext: wptk

Applicable to:

  • Plesk for Linux

Symptoms

  • Website pages based on WordPress show below error on all pages except the main one:

    CONFIG_TEXT: 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
  • 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)
  1. Log into Plesk

  2. Go to Domains > example.com > PHP Settings
  3. Set PHP FPM application served by Apache and click on OK
  4. Go to Domains > example.com > WordPress > Log in
  5. Go to Settings > Permalinks
  6. Click on Save Changes
Via Plesk GUI(using .htaccess file)
  1. Log into Plesk

  2. Go to Domains > example.com > File Manager > httpdocs

  3. Create the .htaccess with following content:

    CONFIG_TEXT: # 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

  4. Click Save button

Via SSH(using .htaccess file)
  1. Connect to the server via SSH.

  2. Create /var/www/vhosts/example.com/httpdocs/.htaccess with below content:

    CONFIG_TEXT: # 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

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.