WordPress Nginx permalinks


You need to edit your nginx configuration file to
make the permalinks work. We will use the
try_files directive
(available from nginx 0.7.27+) to pass URLs to WordPress’s index.php for
them to be internally handled. This will also work for 404 requests.

If your blog is at the root of the domain (something like
http://www.myblog.com), find the location / block inside the configuration
file, and add the following line to it.

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

Here, Nginx checks for the existence of a file at the URL ($uri), then for a
directory ($uri/). If it doesn’t find a directory or a file, it performs an
internal redirect to /index.php passing the query string arguments as

It should look like this after the edits :

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

If your blog is in a subfolder (say /blog), you’ll have to add an extra
location /blog/ block to your configuration file :

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

After you have finished making the changes in the configuration file, reload
the nginx configuration by :

nginx -s reload

WordPress’ pretty permalinks should work fine now.


Leave a reply

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