1. Home
  2. WordPress
  3. How to make WordPress Permalinks work in Nginx
  1. Home
  2. Linux
  3. How to make WordPress Permalinks work in Nginx

How to make WordPress Permalinks work in Nginx

From a long time I had the eagerness to work on Nginx and finally got the opportunity. Followed LEMP stack installation and installed latest WordPress. Everything works perfectly, except for the permalinks. Unlike Apache,.htaccess does not work in Nginx server. This tutorial explains how to make WordPress Permalinks work in Nginx.

Add the below line of code in your Domain specific Nginx configuration file as shown below:

#vim /etc/nginx/conf.d/tg.conf
location / {
        try_files $uri $uri/ /index.php?q=$uri$args;
}

If WordPress root directory is not the default web root, say ‘domain.com/wordpress’, then change / to /wordpress/

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

Check the nginx configuration for syntax:

# nginx -t

If the nginx configuration syntax is ok, then Restart/Reload your Nginx:

# systemctl reload nginx

Now you change the Permalink in your WordPress admin panel and it should work.

It’s not over, you should be concerned about your website security as well. So go ahead and hide Nginx and PHP version information from HTTP headers and error pages.

If your site is based on WordPress, then you should check if these 50 things are done in your WordPress installation. Well, it’s for good.

Updated on November 27, 2017

Was this article helpful?

Related Articles

Add A Comment