![]() |
|
Guide Fix WordPress Permalink 404s in aaPanel Free Edition (Nginx) - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: aaPanel (https://adminsforum.com/Forum-aapanel) +---- Forum: aaPanel Guides & Tutorials (https://adminsforum.com/Forum-aapanel-guides-tutorials) +----- Forum: aaPanel WordPress Guides (https://adminsforum.com/Forum-aapanel-wordpress-guides) +----- Thread: Guide Fix WordPress Permalink 404s in aaPanel Free Edition (Nginx) (/Thread-guide-fix-wordpress-permalink-404s-in-aapanel-free-edition-nginx) |
Fix WordPress Permalink 404s in aaPanel Free Edition (Nginx) - DEV - 10-11-2026 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%/. 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 -t5. 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
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 |