Fixed: Nginx 404 Errors on Custom Permalinks After Switching from Apache in Webuzo (VPS)

Fixed: Nginx 404 Errors on Custom Permalinks After Switching from Apache in Webuzo (VPS)

By Reggi, 23 Dec 2022

Switching your VPS web server from Apache to Nginx via the Webuzo panel often breaks custom permalinks. You’ll hit a 404 Not Found error (The requested URL was not found on this server) the moment you try accessing a post via its slug.

The culprit? Nginx doesn’t read .htaccess files. It doesn't know how to handle WordPress (or generic PHP) rewrite rules out of the box. You have to teach it.

Here is the pragmatic fix.

The Fix: Inject the try_files Directive

You need to edit the global Nginx common configuration file.

1. Access the Config File SSH into your VPS as root (or use sudo). Open the common config:

bash
vim /usr/local/apps/nginx/etc/conf.d/common

Prefer Nano? Swap vim for nano. If permission denied, prefix with sudo.

2. Append the Snippet Scroll to the very bottom of the file. Do not edit existing blocks. Paste this clean block at the end:

nginx
location / { try_files $uri $uri/ /index.php?q=$request_uri; }

What this does: It tells Nginx: "Try the exact file ($uri), then try the directory ($uri/), and if both fail, hand off to index.php with the query args intact." This replicates the standard WordPress/Apache rewrite logic.

3. Save & Exit

  • Vim: Press Esc, type :wq!, hit Enter.
  • Nano: Press Ctrl+X, hit Y, then Enter.

4. Reload Nginx

Apply the changes immediately.

Via CLI:

bash
service nginx restart

Via Webuzo GUI: Navigate to Services → Find Nginx → Click the Reload/Refresh icon.


Result

Your custom slugs/URLs should now resolve perfectly. No more 404s on pretty permalinks.


Popular Reads