• TechOps

    Need clarity?
    Chat with our experts now

    • Web Hosting SupportWeb Hosting Support
    • Helpdesk Support

      Skilled and professional 24/7 helpdesk support

    • Product Support

      Boost your product support with our expertise

    • Managed ServicesManaged Services
    • Server Management

      Don't let server issues slow you down. Let us manage them for you

    • Server Monitoring

      Safeguard your server health with our comprehensive monitoring solutions

    • Staff AugmentationStaff Augmentation
    • Hire an Admin

      Transform your business operations with our expert administrative support

    • Hire a Team

      Augment your workforce with highly skilled professional from our diverse talent pool

  • CloudOps

    Confused?
    Discuss with our sales team now.

    • Author ProfileAWS
      Well Architected Review
    • Author ProfileFinOps As a Service

      FinOps As a Service

    • Migrate

      Upgrade the journey: Migrate & Modernize seamlessly

    • Modernize

      Effortless CloudOps mastery for seamless cloud management

    • Optimize

      Efficient CloudOps: Boosting performance through optimization

    • Manage

      Simplify compliance complexities with our dedicated service

  • DevOps

    How Supportsages
    is creating an
    impact?

    View Casestudies
    • Author Profile24/7 DevOps As a Service

      Round-the-clock DevOps for uninterrupted efficiency

    • Author ProfileCI/CD Pipeline

      Automated CI/CD pipeline for seamless deployments

    • Author ProfileInfrastructure As a Code

      Crafting infrastructure with ingenious code

    • Author ProfileDevSecOps

      Integrated security in continuous DevOps practices

    • Author ProfileHire DevOps Engineers

      Level up your team with DevOps visionaries

    • Author ProfileConsulting Services

      Navigate success with expert DevOps consulting

  • SecOps

    Expert SecOps Services
    for any Scale

    • Author ProfileVAPT

      Vulnerability Assessment and Penetration Testing

    • Author ProfileSource Code Review

      Ensuring source code security and safe practices to reduce risks

    • Author ProfileSecurity Consultation

      On demand services for improving server security

    • Author ProfileSystem Hardening

      Reduced vulnerability and proactive protection

    • Author ProfileManaged SOC

      Monitors and maintains system security. Quick response on incidents

    • Author ProfileCompliance as a Service

      Regulatory compliance, reduced risk

  • Insights

    Explore our latest
    insights and resources

    Blog

    Explore our latest articles and insights

    Case Studies

    Read about our client success stories

  • Contact Us

  • About
  • Certifications
  • Life at Supportsages
  • Events
  • Contact
  • Careers
  • Blog

  • Dedicated Support Team
  • Quasi-dedicated Support Team
  • Hire a DevOps Engineer
  • Hire a Billing Support Staff
  • Per-ticket Support Plan
  • Managed Services

  • Microsoft Azure Expert
  • AWS Cloud Expert
  • Hire a developer
SS

SupportSages

Bites of wisdom @ work


Copyright © 2008 - 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

WordPress Permalink configuration for Nginx

George K.

  • 4 min read
WordPress Permalink configuration for Nginx

Generating audio, please wait...

On Nginx WordPress Permalinks we came across an issue where all links in a WP/Osclass site throws 404 error. This is a typical behaviour of WP/Osclass permalinks configuration issue.

The first step is to confirm it is a Nginx WordPress permalinks issue.

The configuration file for Nginx is /etc/nginx/nginx.conf and it specified the log file for Nginx as /var/log/nginx/error.log

The error log contained the following information

 2014/02/03 06:17:04 [error] 18596#0: *1538 "/home/user/public_html/demo/index.php" is not found (2: No such file or directory), client: xx.xx.xx.xx, server: www.domain.com, request: xxxxxx/xxxx/xx " host: "domain.com/demo" 

The folder “demo” was missing in the document root.

The .htaccess file had the following entries for WP permalink activation


<IfModule mod_rewrite>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Hower Nginx won’t accept .htaccess file and the permalinks specified in the file will not applied. Hence  custom redirect rules are to be added in the Nginx configuration file.

Let us have detailed look into the configuration file. The Virtual host entry configuration details specified in /etc/nginx/nginx.conf are given below


# Virtual Host Configs
include /etc/nginx/conf.d/*.conf;
include /opt/pifpm/sites-enabled/*.conf;
include /opt/pifpm/sites-proxied/*.conf;

As mentioned in the above entries the active virtual host entries are stored in the location /opt/pifpm/sites-enabled/

root@hostname[/opt/pifpm/sites-enabled]# ls -l
total 40
drwxr-xr-x. 2 root root 4096 Feb 3 06:26 ./
drwxr-xr-x. 17 root root 4096 Jan 15 03:43 ../
-rw-r--r--. 1 root root 2202 Jan 10 17:09 forum.domain1.pl.conf
-rw-r--r--. 1 root root 2140 Jan 7 00:12 domain2.pl.conf
-rw-r--r--. 1 root root 2458 Jan 10 17:09 domain3.pl.conf

 

The domain in question is domain1.pl, hence the configuration is domain1..pl.conf . Let us have a look into it. The most relevant entries are given below

server {
listen xx.xx.xx.xx:80; ## listen for ipv4;

root /home/user/public_html/demo;
include /opt/pifpm/nginx.include.d/demo.domain1.pl.indexprio;

access_log /usr/local/apache/domlogs/demo.domain1.pl;

# Server name and its aliases
server_name www.demo.domain1.pl demo.domain1.pl;

include /opt/pifpm/nginx.include.d/demo.domain1.pl.autoinclude;

location / {include /opt/pifpm/nginx.include.d/demo.domain1.pl.include;}
##Additional_locations

 

As you can see from the configuration, it contains the IP, DocumentRoot, access_log location ,server name etc.

The permalink redirect rule for Nginx is given below

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

Add this to the location directive include file ie /opt/pifpm/nginx.include.d/demo.domain1.pl.include

Once this is done, restart Nginx

/etc/init.d/nginx restart

If you receive the following error

# /etc/init.d/nginx restart
nginx: [emerg] "try_files" directive is duplicate in /opt/pifpm/nginx.include.d/demo.domain1.pl.include:1
nginx: configuration file /etc/nginx/nginx.conf test failed

It could be an issue with the directive. In such case, you need to  provide complete directive in the include file as given below

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

Once this is done, restart the  webserver

[~]# /etc/init.d/nginx restart

You can safely ignore the warnings and can proceed with the check. In my case, it worked like a charm

Get 24/7 expert server management

  • Apache
  • Howtos
  • Troubleshooting

Looking for AWS Experts?

We provide top-of-the-line custom AWS setup services tailored to your needs.

.htaccess based mod_rewrite not working with Godaddy ?

.htaccess based mod_rewrite not working with Godaddy ?
  • Apache
  • General
  • Howtos
  • Linux
logo

/proc explained

/proc explained
  • Linux
logo

A story of Ubuntu – I am what I am because of who we all are :)

A story of Ubuntu – I am what I am because of who we all are :)
  • General
  • Training
logo

Account Creation: Sorry, a mysql user with the name x already exists.

Account Creation:  Sorry, a mysql user with the name x already exists.
  • MySQL
  • Troubleshooting
logo
WordPress Permalink configuration for Nginx

Posts by George K.

George started his career in web hosting and Linux technical support in the year 2004 and is with SupportSages since 2009. He has keen interest in server optimizations, custom security solutions, hacked server recovery, cyber forensic and high availability fail over system design and implementation. George loves long drives and is passionate about art and literature.