WordPress Rewrite Rules For Permalinks On Nginx

If your WordPress installation is running on Apache, with mod_rewrite, WordPress will automatically add the required rewrite rules to your .htaccess. But if you are using Nginx, then you have to add the required rewrite rules manually.

WordPress NGINX Rewrite Rules

You will need to edit nginx configuration file for the permalinks to work. Locate the location block and add the following to it.

try_files $uri $uri/ /index.php?$args;

When you are done, it should look something like the following:

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

If your WordPress is in a subfolder, say blog, then you’ll have to add an extra location /blog/ block to your configuration file.

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

Now you will have to save the changes made to the nginx configuration file and restart the Nginx.

/etc/init.d/nginx reload

That is all, permalinks should be working on your WordPress site now.