in Wordpress

How to fixe WordPress permalinks 404 error on Nginx server

5.00
1 Star2 Stars3 Stars4 Stars5 Stars
Ratings: 5.00/5 from 1 users.
Loading...

WordPress is one of the most popular open source content management systems today, and it’s written in PHP, and both PHP and WordPress can run on NGINX.

Nginx make sites faster, but it definitely has an upper edge in serving static content. That’s why, many WordPress users switch to Nginx.

Often, this switch cause Nginx WordPress permalinks 404 errors. This happens as Apache’s rewrite rules do not work with NGINX.

Details of WordPress permalinks 404 error

Only the home page is working, where as every other page returns a 404 not found error.

What causes permalinks 404 error in Nginx?

Nginx and Apache rewrite rules have totally different format. The directives in Apache like Rewritecond, RewriteRule, etc. take its equivalents in Nginx configuration.

mod_security rules will not work with NGINX, and .htaccess rewrite rules and restrictions will no longer apply.

This means that WordPress permalink rewrites will no longer work after switching the web server.

Fixing WordPress permalinks 404 error on Nginx server

  • Converting rewrite rules to Nginx format

A quicker method to fix the permalink error is to convert the Apache rewrite rules to Nginx format. Either we can manually rewrite the rules or use various plugins for automatic conversion.

  • Modifying Nginx configuration

Similarly, modifying the Nginx configuration also helps in solving the WordPress permalinks 404 error.

Edit the following location block within the server block:

location / {
try_files $uri $uri/ /index.php?$args;
}

 

Related Posts

Written By:

Blog for everything about hosting, website, server and technical support

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.