WordPress Permalinks with Nginx

If you use LAMP stack (Linux-Apacke-Mysql-PHP)  WordPress will try to automatically add the required lines in your .htaccess file. You only have to change the option in your Settings > Permalinks tab.

Permalink Settings

With Nginx you need to edit your nginx.conf file. First you need to locate where your site configuration is.

server_name www.joskov.net joskov.net;
location / {
  index index.php index.html index.htm;
}

You need to add a line inside your location block, it should look like this

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

If your site is inside a sub directory of your domain you should specify that too

try_files $uri $uri/ /some-sub-dir/index.php?$args;

Remember to restart your nginx

/etc/init.d/nginx restart

Leave a Reply