In my last post I mentioned that I’d moved Zhou Liang’s blog to the imzl.com domain, with the server migrated to Aliyun ECS in Hangzhou. Migrating the files, setting up the new server environment, deploying the HTTPS certificate, 301-redirecting the old domain, pushing static files to Aliyun OSS — all of it was familiar territory by now. The whole process went smoothly, except for one strange issue that surfaced after the site went live.
WordPress was no longer correctly redirecting error pages to the 404 page.
What Was Happening
The symptoms looked like this:
- Visiting
https://imzl.com/404/— a non-existent URL — should normally hit the Nginx settings or the WordPress theme’s built-in 404 page. Instead, it was just rendering the blog’s homepage content. - Visiting
https://imzl.com/404.html— also a non-existent URL — correctly returned the 404 page.
Confusing, right? In other words, any URL on the blog that didn’t end in .html would render the homepage instead of a 404 page. Terrible UX.
Investigation Path
Let me walk through the diagnosis. You may not run into this exact issue, but the step-by-step logic of controlling variables and testing hypotheses might be useful.
Check the WordPress Theme
First guess: maybe the theme was buggy. Swap to a known-good theme and test. I happen to maintain two blogs, so I swapped both to the same theme and tested. Both behaved correctly — so the theme wasn’t the cause.
Check the Nginx Configuration
Since this is a redirect issue, my next guess was a misconfigured Nginx rule. I cross-referenced my config against the WordPress Nginx documentation and confirmed the rules were correct. So the rules weren’t to blame.
But I couldn’t rule out Nginx entirely. I applied the same ruleset to another site, and it worked fine. Comparing the two setups variable by variable, I noticed Aliyun was hosting two sites while my test VPS only had one. On a hunch, I added a second site to the test VPS — and the bug reproduced. That basically confirmed the issue lay in the Nginx config.
The Fix
I don’t tinker with Nginx often — I usually stick to a handful of go-to rules. So I went straight to asking an expert. Since the server is set up with LNMP, I reached out to @JunGe, the author of the LNMP one-click installer. I described the symptoms, the steps I’d taken, and the results.
His guess: Nginx had pathinfo enabled, and that was the cause.
How to Disable PathInfo on an LNMP WordPress Site
- Find your Nginx config file — usually under /usr/local/nginx/conf.
- Locate the line include enable-php-pathinfo.conf;
- Change it to include enable-php.conf;
- SSH into the server and run service nginx restart to restart Nginx.
- Done — issue resolved.