AdminsForum

aaPanel WordPress Guides

Guide Fix WordPress Permalink 404s in aaPanel Free Edition (Nginx)

Started by DEV 0 replies 51 views
1DEV
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#1
Quick answer
If WordPress pages work with ?p=123 but pretty post URLs return 404 on aaPanel with Nginx, check both WordPress Settings → Permalinks and the site's Nginx rewrite configuration. Saving WordPress permalinks does not make Nginx read .htaccess.

Before changing rules
Back up the current rewrite configuration and record the current WordPress permalink setting. Confirm the site's web server is Nginx and whether WordPress is installed at the domain root or inside a folder. This guide is for a single WordPress installation, not Multisite.

1. Choose the WordPress URL format
Log in to WordPress, open Settings → Permalinks, choose Post name if that is the structure you want, and click Save Changes. On our fresh lab site the structure changed from plain query URLs to /%postname%/.

[Image: attachment.php?aid=26]
AdminsForum WordPress lab: Post name selected in Permalink Settings.

For an established site, changing public URL structure needs a redirect plan for existing links. This example uses a new disposable lab site.

2. Open the aaPanel rewrite configuration
Open Website → the intended site's settings → URL rewrite. Read and back up the existing rules before editing. Preserve unrelated HTTPS redirects and other application rules. Do not create duplicate location blocks.

Nginx needs a fallback to WordPress index.php for URLs that are not physical files. The official WordPress Nginx documentation describes this approach.

3. Use the rule matching the installation folder
Our lab has WordPress in /wordpress/, while the domain root contains other tutorial examples. We added this site-specific block to its rewrite configuration:
Code:
# AdminsForum WordPress subfolder tutorial location /wordpress/ { try_files $uri $uri/ /wordpress/index.php?$args; }

This checks for an existing file or directory first, then sends other requests in that folder to WordPress. Query parameters are retained. The site's existing aaPanel PHP handler remains responsible for executing PHP.

If WordPress is installed at the domain root instead, the usual fallback is:
Code:
location / { try_files $uri $uri/ /index.php?$args; }

Choose the correct block, not both indiscriminately. The root example assumes the root is actually your WordPress installation. If a matching location already exists, update that block rather than adding a duplicate. Custom proxies, caching, Multisite or other applications need configuration suited to their setup.

4. Save and validate
Save the aaPanel rewrite configuration and confirm there is no configuration error. An operator with SSH can also run the aaPanel Nginx binary's configuration test:
Code:
/www/server/nginx/sbin/nginx -t
Only reload a valid configuration. If validation fails, restore your saved rules and investigate the exact error. Our lab configuration passed before reload.

5. Test an actual post URL
Open a published post using its new URL, not only the homepage. Our lab test was /wordpress/hello-world/. It returned HTTP 200 and the expected post title after the change.

Also check a page, the WordPress homepage, existing static files and any other applications sharing the domain. Our domain homepage and File Manager demo continued returning HTTP 200.

Rollback
Restore the previous rewrite configuration if the new rules cause problems. If you changed WordPress's permalink structure, restore the recorded previous setting as appropriate. Preserve the existing PHP and HTTPS configuration rather than replacing the whole virtual host.

Common problems
  • Duplicate location error: edit the existing matching location instead of adding another.
  • Homepage works but posts 404: verify the fallback path and installation folder.
  • Other applications stop working: a root-level catch-all may be routing their requests to WordPress. Use a correctly scoped block.
  • PHP source is exposed: stop and repair the site's PHP handler before proceeding; a rewrite rule alone is not PHP configuration.
  • Redirect loops: review HTTPS/proxy and WordPress home/siteurl settings separately.

Verified on 11 October 2026
We backed up our lab's existing rewrite configuration, added a /wordpress/ fallback, passed the Nginx configuration test, selected Post name through the WordPress dashboard and tested the published post URL. WordPress 7.1.3 ran on PHP 8.5.11 with aaPanel Free Edition 8.0.6. The domain homepage and original static demo remained available.

Related guide: Install WordPress manually in aaPanel Free Edition

Attached Files

Image(s)
   
Reply
Possibly Related Threads…matched by title
Replies:0Views:46
Replies:0Views:40
Replies:0Views:51
Replies:0Views:51
Replies:0Views:51

Users browsing this thread: 1 Guest(s)
Forum Jump: