WordPress Permalink Change: Posts Returning 404 Not Found (Nginx) Print

  • 243

This article addresses a common issue encountered after changing permalinks in your WordPress website hosted on Systron.net with Nginx as the web server. You might experience a situation where the website loads correctly, but individual posts return a 404 Not Found error.

Understanding the Problem:

WordPress uses permalinks to define the URL structure for your posts, pages, and categories. When you change the permalink structure, WordPress doesn't automatically update the existing URLs on your server. This mismatch between the expected URLs and actual server files leads to 404 errors for posts.

Resolving the Issue:

Here are two effective methods to fix the 404 errors after a permalink change on a Systron.net Nginx server:

Method 1: Using WordPress Rewrite Rules

  1. Login to your WordPress dashboard.
  2. Navigate to Settings > Permalinks.
  3. Choose your desired permalink structure (e.g., Post name).
  4. Save Changes.

Important: This step doesn't directly update the server configuration. However, WordPress automatically adds rewrite rules to the .htaccess file (located in your website's root directory). These rules instruct Nginx to redirect requests for old permalinks to the corresponding new URLs.

Method 2: Manual Nginx Configuration Update

  1. Access your Nginx server configuration file. The location of this file can vary depending on your setup. Typical locations include:
    • /etc/nginx/nginx.conf
    • /etc/nginx/sites-available/<your_domain_name>.conf
  2. Locate the section specific to your WordPress website. Look for blocks containing directives like server_name and root.
  3. Add the following code snippet within the server block:
location / {
  try_files $uri $uri/ /index.php?$args;
}
  1. Save the changes to the Nginx configuration file.
  2. Restart the Nginx service using the command:

    sudo service nginx restart
    

Explanation of the Code Snippet:

The try_files directive instructs Nginx to try the following options sequentially:

  • Check if the requested file ($uri) exists.
  • Check if the requested file with a trailing slash ($uri/) exists (useful for directory listings).
  • If none of the above exist, rewrite the request to index.php along with any query string parameters ($args). This allows WordPress to handle the request and potentially generate the correct permalink.

For aaPanel Step to resolve this issue.

Wordpress Permalink change Causes site to load perfectly but posts give 404 not found nginx. The problem gets solved by adding the following to config as follows:

 

Additional Tips:

  • Always back up your Nginx configuration file before making any changes.
  • If you're unsure about modifying server configuration files, consider contacting Systron.net support for assistance.
  • After implementing one of these methods, clear your browser cache and try accessing your posts again.

Conclusion:

By following these steps and understanding the underlying cause, you should be able to resolve the 404 Not Found errors after changing permalinks on your WordPress website hosted on Systron.net with Nginx.


Was this answer helpful?

« Back