WordPress site shows 404 error

Refers to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 11.5 for Linux
  • Plesk 12.0 for Linux

Created:

2016-11-16 12:47:44 UTC

Modified:

2017-02-26 16:16:17 UTC

3

Was this article helpful?


Have more questions?

Submit a request

WordPress site shows 404 error

Symptoms

Option Process PHP through Nginx in Plesk > Domains > domain.tld > Web Server Settings is enabled and WordPress site domain.tld is working fine.

But after configuring Permalinks in WordPress admin > Settings > Permalinks for site domain.tld to Post name all pages except the main one are showing 404 Not Found error.

Cause

WordPress permalinks are using .htaccess file to rewrite page urls to http://domain.tld/page_name/ .

Nginx is unable to read .htaccess file, this file can be read only by Apache.

When Nginx + php-fpm is set to process php, Apache is not involved into process at all.

Resolution

There is two possible solutions, the first one will be useful if you want to configure PHP-fpm support for one or several WordPress websites, the second one will be useful if you have a huge amount of subscriptions with this issue.

  1. Create additional nginx directive for domain in Plesk > Domains > domain.tld > Web Server Settings :

    if (!-e $request_filename) {
    rewrite ^.*$ /index.php last;
    }
  2. Create custom configuration template files:

    1. Copy default configuration templates as shown below:

      # mkdir /usr/local/psa/admin/conf/templates/custom
      # mkdir /usr/local/psa/admin/conf/templates/custom/domain
      # mkdir /usr/local/psa/admin/conf/templates/custom/domain/service
      # cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
      # cp /usr/local/psa/admin/conf/templates/default/domain/service/nginxWordpressIndexing.php /usr/local/psa/admin/conf/templates/custom/domain/service/nginxWordpressIndexing.php

      Note that any changes made in default configuration templates will be lost after installation of Plesk microupdates.

    2. In file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php replace section:

      location ~ /$ {
      <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
      }

      with the following one:

      location ~ / {
      index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
      try_files $uri $uri/ /index.php?$args;
      }
    3. In file /usr/local/psa/admin/conf/templates/custom/domain/service/nginxWordpressIndexing.php replace

      location ~* "^<?php echo $OPT['ssl'] ? $wordpress->httpsLocation : $wordpress->httpLocation; ?>" {

      with

      location ~* ^/<?php echo $wordpress->location; ?> {
    4. Re-create web-server configuration files:

      # /usr/local/psa/admin/bin/httpdmng --reconfigure-all
Have more questions? Submit a request
Please sign in to leave a comment.