Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Servers»Nginx»How to Configure Nginx for WordPress Permalinks

    How to Configure Nginx for WordPress Permalinks

    By RahulApril 2, 20202 Mins ReadUpdated:November 11, 2022

    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.

    nginx Permalinks WordPress
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Configure CORS in NGINX

    How to Enable CORS in Nginx

    10 Simple Ways to Speed Up Your WordPress Website

    10 Simple Ways to Speed Up Your WordPress Website

    How To Install LEMP Stack on Ubuntu 22.04

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    View 3 Comments

    3 Comments

    1. Annoyed User on November 4, 2022 1:24 pm

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

      Reply
    2. Madusanka on January 27, 2022 6:36 am

      This does not work. Goes to 404 when used “Post Name” Permalink

      Reply
    3. Eduardo Cere on January 31, 2021 1:20 am

      I just can’t make this work! I get “File not found” everytime I click a link on the home page.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Backing Up Your Linux System with Rsync: A Step-by-Step Guide
    • Sort Command in Linux with Practical Examples
    • How to Install and Use Flask in Fedora 37/36
    • Sed Command in Linux with 15 Practical Examples
    • How to Print a List without Brackets in Python
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.