Nginx Config for Perma Links

NGINX Config Change to enable Permalink changes :

By default WordPress links are configured similar to ” “. If you need to change this URL to be something SEO friendly and other than default URL which points to the ID , you can choose the option but it would result 404 Page without NGINX Config file tweak.

NGINX Config File tweak needed to make this work :
In the location block simply add try_files line after index.


location / {
            root   /usr/www/ramblingsofraju;
            index  index.html index.htm index.php;
           try_files $uri $uri/ /index.php?q=$uri&$args;

The try_files option will return the $uri file if it exists, if it does not it checks if the $uri/ directory exists, and if that also does not exist it will internally send the request to /index.php?q=$uri&$args

After adding the try_files option you need to save and reload the configuration or restart the NGINX.

$ sudo nginx -s reload
$ sudo service nginx restart

Permalink Settings

By default WordPress uses web URLs which have question marks and lots of numbers in them; however, WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A number of tags are available, and here are some examples to get you started.

Common Settings

SEO Friendly Perma Links
SEO Friendly Perma Links

Leave a Reply

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