Enabling WordPress permalinks on nginx

WordPress includes support for permalinks on nginx since version 3.7. However, the drawback is that WordPress is not aware of the location of your nginx config file. So you must edit that, and reload the nginx config, in order for permalinks to work on a new wordpress site.

This discussion on WordPress.org’s support site contains detailed information: link.

The TL;DR is this:

  • Open up your nginx site config file in the editor of your choice
  • If you already have a ‘location / { … }’ block, add this line to it, at the beginning:
    • try_files $uri $uri/ /index.php?q=$request_uri;
  • If you do not have a ‘location / { … }’ block, add the following code to your config file:
    •         location / {
      try_files $uri $uri/ /index.php?q=$request_uri;
  • Save, and exit your text editor
  • Reload the nginx configs

Make sure you enable permalinks in your WordPress config, and you’re off to the races.