Permalinks is a URL structure that can link to a specific blog post. It is also used to create archives and pagination links. The permalink allows you to have an anchor point for any blog post, regardless of the path name. WordPress is a popular content management system (CMS) written in PHP. MySQL is the backend database server for WordPress. It maintains its URLs with a permalink, the full URL of any post, page, or other website content. Apache web server uses .htaccess to manage permalinks for WordPress. Nginx doesn’t follow .htaccess, So we need to make changes in the Nginx configuration to follow permalinks by the Nginx web server.

Advertisement

Setup Nginx for WordPress Permalinks

A WordPress website/blog can be run on the main domain or with a directory URL. For example, your blog is running with the main domain. Edit the Nginx configuration file and add the following line under the location section.

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

If you are running your blog under subdirectory URL like /blog, use location a /blog block to your configuration file

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

Save your file and restart the Nginx service.

systemctl restart nginx.service 

That’s it. Now WordPress will be accessible with configured permalinks under the General settings.

Change WordPress Permalinks

The default WordPress permalinks are not SEO friendly, which is not good for the SEO of your application. You need to change permalink settings to make URLs SEO-friendly. To change permalinks, Login to admin panel >> Settings >> Permalinks option.

Default Permalinks:

  • https://tecadmin.net/?p=101

SEO Friendly Permalinks:

  • https://tecadmin.net/post-name
  • https://tecadmin.net/category/post-name
  • https://tecadmin.net/2020/01/22/post-name

Wordpress permalinks setting

Conclusion

URLs play a good role in website SEO. In WordPress, you can change the URL type by configuring the permalink settings. This tutorial helped you to configure the Nginx web server to handle custom permalinks of WordPress.

Share.

3 Comments

  1. Absolutely useless. It seems all of the internet has copy-pasted this from the same initial blog without ever trying it…

Leave A Reply


Exit mobile version