Skip to content

WordPress .htaccess rules for Nginx

This guide shows you the equivalent .htaccess rewrite rules to get WordPress working properly with permalinks on the Nginx web server.

There is no direct equivalent for .htaccess in Nginx, so you cannot copy and past the .htaccess rules that WordPress suggests when you change your permalink settings in the dashboard. Instead you need to add the following rules to you site local configuration file.

You could put these rules in the global nginx.conf file, generally found at…

…but it is much better practice to have a single configuration file with local overrides for each site you are hosting on your Nginx server. Not only does this lead to granular management on a site by site basis, but it also avoids issues that may occur with multiple PHP apps (Drupal, Joomla! etc) each requiring slightly different rewrite rules.

First of all either create or edit the configuration file for your site.

The standard configuration file looks something like this. This is the file used for

Now for a single WordPress installation (not multisite) you need to add the following to this file.

For a multisite WordPress installation you need to add this.

After adding the rules remember to restart Nginx.

Please note, after restarting Nginx you may need to reset your permalink settings in the WordPress dashboard. Just reselect the type of permalinks you want and click save again.

As usual if you have any problems leave a comment and we will do our best to help you out!


  1. Lewis Lewis


    You mention what code to add but no mention of where to add it. It would be great if you could add this as I added it and it’s errored.




      Add it to a .htaccess file in the relevant web root. Normally something like /var/www/vhosts/

Leave a Reply

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