WordPress nginx permalinks not working

You may have recently switched from apache to nginx web server and realized that the rewriting structure of nginx is totally different from the apache one. First of all nginx doesn’t use .htaccess file normally, secondly the commands used in the nginx.conf file for the site aren’t the same syntax as the .htaccess one.

wordpress 4.0Please note, that some may argue that .htaccess can be used with nginx, well if you want to follow that way please carry on! that way you will be saved from the hassle of understanding the nginx configuration and commands for the permalinks and other stuff that can be done with .htaccess. However, that way isn’t ideal imho, as it’s not native to nginx. If you’ve shifted to nginx then why not utilize the maximum potential of nginx by using the native features of the system!

WordPress nginx permalinks not working – Solution

So coming back to the point, if your nginx permalinks aren’t working for your wordpress site, then you simply need to make a modification in your nginx configuration file. Follow these steps:

  1. login to ssh and goto folder: /etc/nginx/sites-available/ (the folder may vary if you named something differently)
  2. open the websites configuration file (e.g.: nano website.com )
  3. Search for the part that says:
    •     location / { }
  4. In this code block, find the line line:
    •     try_files $uri ………….; (the … part can be any code other than the one below)
  5. and replace it with (you can add # before the above line and add this one under it so that you have the original previous code as backup for future reference just in case):
    •     try_files $uri $uri/ /index.php?$args;
  6. save the file
  7. reboot nginx

Voila, now go and change the permalinks again and they should be working absolutely fine!

Let me know if you need any assistance or want my services to do it for you on your site!

Leave a Reply

Your email address will not be published.