Howtos / Articles

Enable Permalinks in WordPress on Nginx

A default installation of WordPress on Nginx is not going to allow the use of Permalinks.

Since Nginx doesn’t support the Apache .htaccess files, the Nginx configuration files need to be edited manually to suit.

To enable permalinks in Nginx:

Edit the configuration file associated with your WordPress site.


$ sudo nano /etc/nginx/sites-enabled/sitename.conf

Locate the “location /” code block, located within the “server” block, and add the following line within:

try_files $uri $uri/ /index.php?q=$uri&$args;

Example config file:

server {
        listen 80 default;
        root /var/www/sitename;
        index index.php index.html index.htm;
        error_page 404 /404.html;
        port_in_redirect off;

        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;

        location ~ \.php$ {
            try_files $uri =403;
            fastcgi_pass unix:/var/run/php5-fpm-websites.sock;
            include fastcgi_params;

        location ~ /\.ht {
            deny all;

You should now be able to make use of permalinks in WordPress running on a Nginx server.

Share this howto article!
  • Facebook
  • Twitter
  • Reddit
  • email

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>