How7o
  • Home
  • Marketing
    MarketingShow More
  • OS
    OSShow More
    How to force quit frozen apps in Ubuntu
    Force Close an App in Ubuntu (xkill, System Monitor, kill -9)
    4 Min Read
  • Features
    FeaturesShow More
  • Guide
    GuideShow More
  • Contact
  • Blog
Reading: Configure Nginx for WordPress in aaPanel (Fix Permalink 404 Errors)
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Categories
    • Marketing
    • OS
    • Features
    • Guide
    • Lifestyle
    • Wellness
    • Healthy
    • Nutrition
  • More Foxiz
    • Blog Index
    • Complaint
    • Sitemap
    • Advertise
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Server Management > Configure Nginx for WordPress in aaPanel (Fix Permalink 404 Errors)
Server Management

Configure Nginx for WordPress in aaPanel (Fix Permalink 404 Errors)

how7o
By how7o
Last updated: January 23, 2026
5 Min Read
Configure Nginx for WordPress in aaPanel (fix 404 permalinks)
SHARE

I used Apache for years, so I got spoiled by one thing: .htaccess. Upload WordPress, enable permalinks, and Apache just “gets it.”

Contents
  • Why WordPress works on Apache but 404s on Nginx
  • Fix: Configure Nginx rewrite rules for WordPress in aaPanel
    • Step 1: Open your site settings in aaPanel
    • Step 2: Paste this Nginx configuration (WordPress permalinks fix)
    • Step 3: Check the PHP-FPM socket path (important)
    • Step 4: Re-save WordPress permalinks (flush rules)
  • Quick troubleshooting if it still shows 404
  • Optional: Small performance tweaks (safe defaults)
  • Final thoughts

Then I decided to move one of my sites to Nginx in aaPanel (because everyone keeps recommending Nginx for performance). The homepage loaded perfectly… but every single post and page URL showed 404 Not Found.

At first I thought WordPress was broken. Nope. The real issue was simple: Nginx does not use .htaccess. So if your WordPress site depends on permalinks (pretty URLs), you must add the rewrite rules in the Nginx config (aaPanel makes that easy once you know where to put it).

Why WordPress works on Apache but 404s on Nginx

WordPress “pretty permalinks” (like /how-to-fix-x/) rely on rewrite rules. On Apache, those rules usually live in .htaccess.

On Nginx, there is no .htaccess. The rewrite logic has to exist in the Nginx server block, typically with something like try_files that routes unknown URLs to index.php (so WordPress can handle them).

Fix: Configure Nginx rewrite rules for WordPress in aaPanel

In aaPanel, most things are already preconfigured. You just need to paste the correct rewrite rules in the right place.

Step 1: Open your site settings in aaPanel

  • Log in to aaPanel
  • Go to Website
  • Find your domain and click Settings
  • Open the URL Rewrite tab

If aaPanel has a “WordPress” rewrite template, you can select it. If not (or if it still 404s), paste the rules below.

Step 2: Paste this Nginx configuration (WordPress permalinks fix)

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

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

location ~ \.php$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/tmp/php-cgi.socket;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

Click Save. In many setups aaPanel reloads Nginx automatically. If it doesn’t, reload it (there’s usually a reload button inside aaPanel’s Nginx section).

Step 3: Check the PHP-FPM socket path (important)

This is the one part that can vary. Your config uses:

fastcgi_pass unix:/tmp/php-cgi.socket;

That’s common on aaPanel, but depending on your PHP version and setup, it might use a different socket path.

If you still get errors after adding the rewrite rules, check what PHP-FPM is listening on. You can confirm via SSH like this:

sudo grep -R "listen =" /www/server/php/*/etc/php-fpm.conf 2>/dev/null

Then update the fastcgi_pass line to match the socket you actually have, save, and reload Nginx.

Step 4: Re-save WordPress permalinks (flush rules)

After switching web servers, I always do this once:

  • Go to WordPress Dashboard → Settings → Permalinks
  • Click Save Changes (even if you don’t change anything)

Now test a few post URLs. The 404s should be gone.

Quick troubleshooting if it still shows 404

  • Make sure your Nginx “location /” contains try_files $uri $uri/ /index.php?$args;
  • Confirm the correct document root is set in aaPanel for that site (points to your WordPress folder)
  • Check PHP is working: create a quick phpinfo() test file (delete it after)
  • Reload Nginx after saving rewrite rules
  • Disable caching temporarily (browser cache / plugin cache / Cloudflare) and test again

Optional: Small performance tweaks (safe defaults)

Once it’s working, you can keep the static caching block (already included above) and consider enabling gzip in Nginx globally (aaPanel usually has a toggle for it). Don’t go crazy with “random Nginx optimizations” unless you’re benchmarking—rewrite rules first, performance second.

Final thoughts

The main difference between Apache and Nginx for WordPress is this: Apache reads .htaccess, Nginx doesn’t. In aaPanel, the fix is simply adding the correct WordPress rewrite rules under URL Rewrite. Once I pasted the try_files rule, all my posts started loading normally.

TAGGED:aapanelfastcgilnmpNginxpermalinksPHP-FPMurl rewritevpswordpress

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Replace Broken Images Automatically with JavaScript Replace Broken Images Automatically with JavaScript (and jQuery)
Next Article Remove Files & Folders in Linux How to Remove Files and Folders in Linux Using Command Line (rm, rmdir, unlink)
Leave a Comment

Leave a Reply Cancel reply

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

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
CyberPanel too many redirects Laravel error fixed by restarting LiteSpeed
Fix CyberPanel Too Many Redirects (ERR_TOO_MANY_REDIRECTS) for Laravel Subdomain
January 23, 2026
How I Fixed Composer Dependency Errors
How I Fixed Composer Dependency Errors Using the –ignore-platform-reqs Flag (Step-by-Step Guide)
January 12, 2026
Transfer Discourse to a new server
How to Transfer Discourse to a New Server on AlmaLinux (Backup + Restore, Step-by-Step)
January 12, 2026
Installed Discourse on AlmaLinux
How I Installed Discourse on AlmaLinux (Docker Method, Step-by-Step)
January 12, 2026
Installing Docker on AlmaLinux guide
Install Docker on AlmaLinux: Step-by-Step (Docker CE + Compose)
January 12, 2026

You Might Also Like

Change welcome message on Ubuntu VPS server (MOTD + SSH banner)
Server Management

Change Welcome Message on Ubuntu VPS (MOTD + SSH Banner)

6 Min Read
WooCommerce homepage filter to hide out of stock products
Web Development

Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)

5 Min Read
Migrating files from cPanel to aaPanel using rsync
Server Management

cPanel to aaPanel Migration with rsync: Fix Permissions, SSH Port, and CSF Firewall

6 Min Read
How to temporarily disable Imunify360 service for testing (cPanel/WHM)
Server Management

How to Temporarily Disable Imunify360 Service (Safe Testing + Fix 503)

5 Min Read

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?