Maintenance

WordPress Pages Showing 404 but the Homepage Works? How to Fix It

WordPress pages showing 404 but the homepage works? Reset permalinks, repair .htaccess or Nginx rules and fix migration and plugin causes, step by step.

WordPress Pages Showing 404 but the Homepage Works? How to Fix It
On this page
  1. WordPress pages 404 but homepage works: why it happens
  2. Step 1: resave permalinks
  3. Step 2: check .htaccess on Apache or LiteSpeed hosting
  4. Step 3: Nginx servers
  5. Step 4: rule out plugins and custom post types
  6. Step 5: after a migration or domain change
  7. Step 6: when URLs really changed
  8. Other 404 patterns and what they point to
  9. Check Search Console afterwards
  10. Prevent it happening again
  11. Quick check: is it the rewrite rules?
  12. When to get help
  13. FAQs
Key takeaways
  • When the homepage loads but every other page returns 404, the rewrite rules are broken: resave permalinks first, then check .htaccess or the Nginx configuration.
  • Migrations, server changes, security plugins and custom post type plugins are the usual triggers, so think about what changed just before the 404s started.
  • After fixing, check Search Console and add 301 redirects for any URLs that genuinely changed, so visitors and Google land on the right pages.

If your WordPress pages show 404 but the homepage works, the problem is almost always the rewrite rules that turn pretty permalinks (like /services/) into something WordPress can load. The quickest fix is to go to Settings, Permalinks in wp-admin and click Save Changes without changing anything. That regenerates the rules. If the 404s come back or the save doesn't help, the .htaccess file (on Apache or LiteSpeed hosting) or the Nginx configuration needs repairing.

Below are the steps in order, from the one-click fix to the server checks, plus the migration and plugin issues that cause this most often.

WordPress pages 404 but homepage works: why it happens

Your homepage is served directly by index.php, so it loads even when rewrite rules are broken. Every other page depends on the server passing the "pretty" URL to WordPress, which then looks up the right post or page. When that handover fails, the server or WordPress returns a 404 for everything except the homepage.

TriggerWhat breaksTypical fix
Site migration or new host.htaccess missing or not copiedResave permalinks, recreate .htaccess
Move to Nginx hostingNginx ignores .htaccessAdd try_files rule in server config
Security or caching plugin edit.htaccess overwritten or corruptedRestore default WordPress block
Custom post type plugin installed or changedNew rewrite rules not flushedResave permalinks
Slug or permalink structure changedOld URLs no longer exist301 redirects from old URLs
Site moved into a subfolderRewriteBase points to the wrong folderCorrect the base path

Log in to wp-admin, go to Settings, Permalinks, and click Save Changes. Don't change the structure. WordPress flushes its stored rewrite rules and, if it can, rewrites .htaccess. Then open a few inner pages in a private window.

If you can't reach wp-admin either, that is a different problem; see common WordPress errors and how to fix them first.

Step 2: check .htaccess on Apache or LiteSpeed hosting

Most shared hosting in India, including cPanel and hPanel hosts, uses Apache or LiteSpeed, which read the .htaccess file in your site's root folder. Open your hosting file manager, show hidden files and look for .htaccess next to wp-config.php.

The standard WordPress block looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  • If the file is missing, create it with the block above.
  • If it exists but has no WordPress block, add the block, keeping any other rules (caching, security, redirects) above or below it as they were.
  • If it is full of unfamiliar rules, download a copy first, then try the clean block alone. Strange redirect rules to other domains can be a sign of a hack, so have the site checked if you did not add them.
  • If WordPress lives in a subfolder, such as /blog/, change RewriteBase and the last rule to that folder.

Check the file permissions too. WordPress can only update .htaccess if it is writable; 644 is the usual setting. WordPress file permissions explained covers this.

Step 3: Nginx servers

Nginx doesn't read .htaccess at all, so resaving permalinks won't help on its own. The server block for the site needs a rule that sends unknown URLs to index.php, typically try_files with $uri, $uri/ and /index.php?$args. On managed or VPS hosting you may need to ask the host's support to add it, or add it yourself in the panel's Nginx settings. This often catches people who have moved from shared hosting to a VPS.

Step 4: rule out plugins and custom post types

If only some pages 404, such as products, portfolio items or a custom post type, the plugin that registers them may have been deactivated, updated or changed its URL base. Reactivate it and resave permalinks. If 404s started right after a plugin update, deactivate plugins one at a time (or rename the plugins folder) to find the culprit; troubleshooting plugin conflicts explains the method.

Also check that two items don't share the same slug, for example a page and a category both called "services", which can send one of them to a 404 or the wrong content.

Step 5: after a migration or domain change

404s on inner pages are one of the most common post-migration problems. Check that:

  • The .htaccess file was copied (hidden files are often skipped).
  • The WordPress Address and Site Address in Settings, General use the new domain.
  • Any search-and-replace on the database included serialised data, done with a proper tool rather than a raw SQL replace.
  • The server's PHP and rewrite module settings match what the old host provided.

If you are planning a move, migrating a WordPress website to a new host lists the checks to do before switching DNS, and website migration and hosting can handle it end to end.

Step 6: when URLs really changed

Sometimes the 404 is correct: the URL no longer exists because a slug was edited, the permalink structure changed from dates to post names, or old pages were deleted. In that case, add 301 redirects from each old URL to its closest new page, using a redirect plugin or server rules. 301 vs 302 redirects explains which type to use, and SEO-friendly URLs in WordPress covers changing permalinks safely.

For pages that are genuinely gone, a helpful 404 page with search and links to your main services keeps visitors on the site.

Other 404 patterns and what they point to

Not every 404 problem affects all inner pages. The pattern tells you where to look:

  • Only page 2 of the blog or a category returns 404. Usually a posts-per-page setting in a theme or plugin that conflicts with Settings, Reading, or a page whose slug matches the blog base. Resave permalinks and check for a page with the same slug as your category base.
  • Images and PDFs return 404 but pages work. The files were not copied during a migration, or the uploads folder path in the database still points to the old server. Check that wp-content/uploads exists and holds the files.
  • Pages work when logged in but 404 for visitors. A cached 404 is being served. Clear the caching plugin, the server cache and any CDN cache, then test again in a private window.
  • Only WooCommerce product or shop pages 404. The shop page setting or product base changed. Check WooCommerce settings and the product permalink base, then resave permalinks.
  • Only URLs with a trailing slash, or without one, fail. A redirect rule or CDN setting is changing the URL. Test both forms and check redirect rules in .htaccess, the CDN and any redirect plugin.
  • wp-admin shows 404. A login-hiding security plugin has moved it. Rename that plugin folder temporarily to get back in.

Write down which URLs fail and which work before changing anything. A short list of examples is the fastest way to explain the problem to your host or developer, and it lets you check the fix properly afterwards.

Check Search Console afterwards

Once pages load again, open Google Search Console, go to Pages and look at "Not found (404)". Use URL Inspection on a few important pages and request indexing if they had dropped out. If the outage lasted only hours, Google usually recovers on its own; longer outages may need a little time for rankings to settle.

Prevent it happening again

  • Take a backup, including .htaccess, before migrations, server changes and major plugin updates.
  • Test a few inner pages, not just the homepage, after every change.
  • Use an uptime monitor that checks an inner page as well as the homepage.
  • Avoid editing .htaccess by hand without a copy of the original.

Regular checks like these are part of WordPress maintenance and support. If the site is down right now and the steps above haven't worked, you can hire a WordPress developer in India to look at the server configuration directly.

Quick check: is it the rewrite rules?

  1. Open Settings > Permalinks and click Save Changes without changing anything. This rebuilds the rewrite rules.
  2. Reload a page that showed 404. If it works now, the rules were the problem.
  3. If it still fails on Apache hosting, open the file manager and check that .htaccess exists in the site root and contains the WordPress rewrite block.

When to get help

Get help when 404s follow a migration or domain change, when Search Console shows many "Not found" URLs, or when old URLs need redirects. WordPress maintenance and support covers permalink, server and redirect fixes, and WordPress migration covers moves done without broken links. You can also send the details through the contact form.

If you need to change the URL structure itself, follow the step-by-step permalinks tutorial first.

FAQs

Why are my WordPress pages showing 404 but the homepage works?

The rewrite rules that handle pretty permalinks are broken or missing. Resave permalinks in Settings, then check the .htaccess file on Apache or LiteSpeed, or the try_files rule on Nginx.

How do I reset permalinks in WordPress?

Go to Settings, Permalinks and click Save Changes without changing anything. This flushes and regenerates the rewrite rules.

Where is the .htaccess file in WordPress?

In the site's root folder, alongside wp-config.php. It is hidden by default, so turn on "show hidden files" in your hosting file manager or FTP client.

Why did my pages show 404 after migrating WordPress?

Usually because .htaccess wasn't copied, the new server uses Nginx, or the site URL settings still point to the old address. Fix those and resave permalinks.

Will 404 errors hurt my Google rankings?

A short outage rarely does lasting harm. If pages stay unavailable for days, Google may drop them from the index, so fix the rules quickly and request indexing for important pages.

Need help with your website?

I'm a freelance WordPress developer building fast, SEO-friendly websites since 2020. Tell me what you need and I'll reply with a plan and a fixed quote, usually within 24 hours.

Found this useful? Share it:
Contact

Let's build your next website

Available for freelance projects, agency white-label work and long-term maintenance. Feel free to pass this along to your team or company.

I reply within 24 hours, usually the same day. Your details are emailed to me, then WhatsApp opens so we can chat right away.

Chat now