Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
VGSOURCES
List your tool

404 errorsPATCH 2026.10.15

How to Fix WordPress 404 Errors on Nginx for All Pages but the Homepage

By VGSources Team 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your WordPress homepage loads on Nginx but every post, page, feed, or /wp-admin/ URL returns 404, the usual cause is an incomplete try_files rule. Nginx is checking only for a matching file or directory and returns 404 before WordPress can resolve the URL. In a normal root installation, change the site’s location / block to try_files $uri $uri/ /index.php?$args;, verify that PHP-FPM handles index.php, test the configuration, reload Nginx, and then retest representative URLs.

Why the homepage works while every other URL fails

The homepage commonly succeeds because it maps to a real file: WordPress’s index.php. A pretty permalink such as /about/, /news/my-post/, or /contact/ usually is not a physical file or directory. WordPress must receive that request through its front controller, index.php, and then use its rewrite and permalink rules to find the requested content.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A typical broken Nginx block ends like this:

location / {
    try_files $uri $uri/ =404;
}

That instruction means “serve the requested path if it exists as a file or directory; otherwise return 404.” Nginx therefore rejects the pretty URL itself. WordPress never gets a chance to generate its own response.

For a standard installation at the web root, the final argument must be the WordPress front controller:

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
try_files $uri $uri/ /index.php?$args;

The first two arguments continue to serve real assets directly. The third sends all other requests to WordPress while preserving the original query string.

What the working single-site configuration looks like

Use the active virtual host for the domain, not an example or disabled file. Paths differ by distribution, PHP version, and hosting platform, so treat the socket, include file, and document root below as values to replace with those used by your server.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    server_name example.com www.example.com;
    root /var/www/example.com/htdocs;
    index index.php;

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

    location ~ .php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}
  • root must be the directory containing this WordPress installation’s index.php, wp-admin, wp-content, and wp-includes.
  • index index.php; tells Nginx which index file to serve for the bare host URL.
  • location / contains the critical front-controller fallback.
  • try_files $uri =404; in the PHP location is a security guard. Keep it so Nginx does not pass nonexistent PHP paths to PHP-FPM.
  • fastcgi_param SCRIPT_FILENAME must resolve to the same installation represented by root.
  • fastcgi_pass must point to your actual PHP-FPM socket or configured upstream; the sample socket is not universal.

Do not remove the PHP guard to “make rewrites work.” The fix is the fallback in location /, not indiscriminate forwarding of every path to PHP.

Repair the configuration safely

1. Confirm which server block is serving the domain

First identify the hostname users are requesting and the Nginx configuration that is actually loaded for it. A correct rule in an unused file has no effect. Inspect the complete loaded configuration with your platform’s equivalent of:

nginx -T

Find the matching server_name, then check its root, location /, PHP location, and any included files. Pay attention to duplicate virtual hosts, a default server that catches the request, and a separate HTTP-to-HTTPS or www/non-www block that may be serving the tested hostname.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

2. Verify the document root

Look in the configured root and confirm that it contains the WordPress index.php. If the root points one directory too high, one directory too low, or to a different site, changing try_files will not repair routing. The root used by Nginx and the script path sent to PHP-FPM must describe the same WordPress copy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Replace the file-only fallback

In the active location / block, replace an ending such as =404 with /index.php?$args:

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

Keep any legitimate static-file handling that precedes this rule, but avoid adding a second competing location / block. Nginx location selection can make a more-specific block win over the one you edited.

4. Check the PHP handler

The fallback only helps if Nginx can execute the resulting /index.php. Confirm that the PHP location includes the expected FastCGI parameters and sends requests to the running PHP-FPM socket or upstream. A PHP handler pointing at another application can produce confusing errors even after the rewrite is correct.

5. Validate before reloading

Run:

nginx -t

Do not reload if the test reports a syntax error, an invalid include, or a duplicate or conflicting location. Correct the reported file and line first. A successful test means Nginx can parse the configuration; it does not by itself prove that the correct virtual host or PHP socket is being used.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

6. Reload the running service

After a successful test, reload Nginx without stopping active connections. The exact command depends on the operating system or control panel; a common direct command is:

nginx -s reload

Use your platform’s service-reload command when Nginx is managed by a service supervisor. If you edited a generated configuration, make sure the platform has regenerated or accepted the change rather than overwriting it on the next deployment.

Retest routing in a deliberate sequence

Test more than the homepage. Use a private browser window or an HTTP client that shows status codes so an old cached response does not disguise the result.

URL to test What it checks Expected result after the fix
/ Root index handling Homepage loads normally
A known page, such as /about/ Pretty-page fallback WordPress page, not an Nginx file-miss 404
A known post URL Post permalink resolution The intended post or WordPress’s own not-found page if the slug is deliberately invalid
A feed, such as /feed/ Non-file endpoint routing Feed response generated by WordPress
/wp-admin/ Administrative path handling Login or dashboard response, subject to authentication
The same page with and without a trailing slash Permalink and redirect behavior The form selected by WordPress’s permalink settings, with any expected redirect

A deliberately invalid slug should not necessarily become an Nginx-generated 404. Once routing works, WordPress can return its own themed 404 page, status code, and headers. Distinguishing those responses helps you tell routing failure from normal application behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Refresh WordPress’s permalink settings

In the WordPress dashboard, open Settings > Permalinks and save the intended permalink structure. This can refresh WordPress’s rewrite state after a migration or structure change. It cannot create an Nginx server rule: Nginx does not read WordPress’s rewrite settings as a replacement for the front-controller fallback. Perform the server repair first, then save the settings and retest.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Why an .htaccess edit does not fix Nginx

Apache uses per-directory .htaccess files for rules that can rewrite requests. Nginx has no equivalent directory-level configuration file. Its routing belongs in the server configuration, normally inside the relevant virtual host and location directives.

Creating or editing an .htaccess file in the WordPress directory therefore does not make Nginx forward /about/ to index.php. It may be harmless leftover configuration from an Apache migration, but it is not the control point for this problem. Make the change in the loaded Nginx configuration and reload the service.

Subdirectory installations need a different fallback

If WordPress is installed below the domain root, include that installation prefix in the fallback. For an installation under /my_subdir/, the pattern is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
location / {
    try_files $uri $uri/ /my_subdir/index.php?$args;
}

The exact root, location layout, and URL prefix must match the documented deployment. Do not copy the root-install rule unchanged: forwarding to /index.php when the real controller is under /my_subdir/ sends requests to the wrong path. Test both prefixed pages and static files after reloading.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Multisite requires topology-specific rules

WordPress Multisite can use subdirectories, subdomains, or a mapped-domain arrangement. The required Nginx directives vary with the WordPress version and network topology, including how administrative paths, uploaded files, and site prefixes are handled. Do not apply the single-site snippet blindly to a network.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Start by identifying whether the network is subdirectory- or subdomain-based and which virtual hosts serve each site. Then use the version-appropriate Nginx rules for that topology, preserving the same principles: the active server block must match the request, the document root must contain the network’s controller, and PHP-FPM must execute that controller. Validate with nginx -t and test the main site, a secondary site, /wp-admin/, and uploads.

Diagnose the remaining failure instead of guessing

The homepage still works, but pages remain an Nginx 404

  • Recheck nginx -T and confirm you edited the server block selected for the exact hostname and protocol.
  • Search the loaded configuration for another location that is more specific than location / and captures the failing path.
  • Confirm the new configuration was reloaded after the edit.
  • Verify that the fallback includes the leading slash and the query-string suffix: /index.php?$args.

The response is a WordPress-generated 404

This is a different condition. It indicates that the request reached WordPress, but WordPress did not find matching content or a valid rewrite. Check the requested slug, the selected permalink structure, and whether the page or post is published. Saving Settings > Permalinks can refresh rewrite state. Inspect both Nginx and PHP logs when the status or page source is unclear.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You see a PHP error or a blank response

Routing may now be correct while PHP execution is not. Check that fastcgi_pass names a running PHP-FPM socket or upstream and that SCRIPT_FILENAME resolves under the same root containing WordPress. Review PHP-FPM and Nginx error logs for the precise script path and failure.

Only some URLs fail

Inspect path-specific locations, redirects, and application rules. A more-specific location can bypass the general fallback. Also compare the failing hostname with the working one; a separate www, non-www, HTTP, or HTTPS virtual host may still contain the old =404 rule.

Old 404s persist after the reload

Once routing is demonstrably correct, purge any reverse-proxy or CDN cache that stored the old response. Purging cannot repair a missing Nginx fallback, so do it after configuration and direct-origin tests succeed. A cache-management plugin such as Nginx Helper can assist with purging, but it does not replace the server rule.

Choosing the right repair path

The technical change is small, but access and operational control determine who should perform it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Best fit Capabilities to confirm Main risk
Self-managed repair You administer the server and can edit the active virtual host Loaded-config access, PHP-FPM control, ability to run nginx -t, reload access, and a rollback copy Editing an unused file or breaking another virtual host
Managed WordPress hosting support The host controls Nginx or exposes only a panel Provider confirmation of the active root, front-controller rule, PHP upstream, backups, and cache purge process Panel changes may be regenerated or hidden from you
Consultant or administrator You need help with a migration, multisite, or several virtual hosts Documented change, configuration validation, reload procedure, logs, and rollback plan A generic single-site snippet being applied to a different topology

Regardless of who makes the change, require a backup of the current configuration, confirmation of the active server block, a successful syntax test, and post-reload tests for pages, posts, feeds, administration, and the site’s chosen slash format.

Prevent the problem during an Apache-to-Nginx migration

  • Inventory every hostname and virtual host before switching DNS or the web server.
  • Map the document root and PHP-FPM endpoint for each WordPress installation.
  • Translate Apache rewrite behavior into Nginx location rules; do not assume .htaccess files will be read.
  • Keep the front-controller fallback and the PHP-file existence guard in separate, purposeful locations.
  • Run nginx -t before every reload and retain the previous working configuration for rollback.
  • Test a real page, post, feed, administration URL, and static asset at the origin before changing cache or CDN state.
  • For subdirectory and Multisite deployments, document the URL prefix or network topology alongside the configuration.

Quick recovery checklist

  1. Use the exact hostname that returns the 404 and locate its active server block with the loaded configuration.
  2. Confirm that the configured root contains the intended WordPress index.php.
  3. Set location / to try_files $uri $uri/ /index.php?$args; for a root single-site install.
  4. Verify that the PHP location sends that index.php to the correct PHP-FPM socket or upstream.
  5. Run nginx -t; fix every reported error before reloading.
  6. Reload Nginx, then test a page, post, feed, /wp-admin/, and both slash forms where relevant.
  7. Save Settings > Permalinks in WordPress if rewrite state also changed.
  8. Only after direct routing works, purge proxy or CDN caches and investigate any remaining application-level 404s in the logs.

404 errorsNGINXPermalinksPHP-FPMWeb Server TroubleshootingWordPress

Leave a reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.