Skip to content
Technology for businesses since 2008

Help center · WordPress

WordPress 404 errors on inner pages: how to fix the permalinks

When only the WordPress homepage loads and internal pages and posts return 404 errors, the most common cause is a .htaccess file that is missing, deleted or has wrong rules. WordPress uses this file to turn addresses such as yourdomain.com/contact/ into a call to index.php. The fix is usually to go to Settings > Permalinks and click Save Changes, which makes WordPress rebuild the rules. If that doesn’t solve it, you need to create the default .htaccess manually through cPanel.

This article is for anyone who manages a WordPress site on cPanel hosting and sees the 404 error everywhere except the homepage. It shows how to confirm the diagnosis, save the permalinks again, rebuild the default file and check other causes, such as a change of server or folder.

Why does only the homepage load?

WordPress doesn’t create a file for each page or post. When someone visits yourdomain.com/about/, the server needs to know that it should hand the request to WordPress’s index.php, which decides what to show. What teaches the server this are the rewrite rules (the mod_rewrite module in Apache) stored in the .htaccess file.

Without these rules, the server looks for a folder or file named about, doesn’t find it and returns a 404 error. The homepage keeps loading because the / address already points to index.php.

What you see Likely cause
Homepage loads, pages and posts return 404 .htaccess missing, empty or without the WordPress rules
404 after migrating the site .htaccess file wasn’t copied (hidden files are left out of some copies)
404 after changing the link structure Outdated rules; saving the permalinks again fixes it
500 error instead of 404 Invalid rule in the .htaccess. See 500 error or white screen in WordPress
404 only on one specific page Address changed, page is a draft or in the trash, or a plugin redirect

This is the simplest fix and solves most cases. If you can log in to the dashboard:

  1. Go to yourdomain.com/wp-admin and sign in with your username.
  2. Go to Settings > Permalinks.
  3. Don’t change anything. Scroll to the bottom and click Save Changes.
  4. Open an inner page of the site in a private window to avoid the browser cache.

When you save, WordPress tries to rewrite the rules in the .htaccess file. For this, it needs write permission for the file. If a message appears saying the .htaccess couldn’t be updated, go to step 3.

If the dashboard doesn’t open, the problem may be something else: see how to recover the WordPress administrator password or the article on 500 errors.

Step 2: check whether the .htaccess file exists

If saving the permalinks didn’t solve it, check the file through cPanel.

  1. In cPanel, open the File Manager.
  2. Click Settings (top right corner) and check Show Hidden Files. Without this, .htaccess won’t appear, because its name starts with a dot.
  3. Go into the site’s folder, the same one that holds wp-config.php and the wp-admin and wp-content folders. On a main domain, this is usually public_html.
  4. Look for .htaccess. If it doesn’t exist, it was deleted or didn’t come with the migration. If it exists, open it with Edit and compare its content with the template in step 3.

Before editing anything, download a copy of the file or duplicate it under another name, such as .htaccess-copy. That way you can undo any change.

Step 3: rebuild the default WordPress rule

The block below is the default content of the .htaccess for a WordPress installed in the main folder of the site, with permalinks set to anything other than “Plain”:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

To apply it:

  1. In File Manager, if .htaccess doesn’t exist, click + File in the site’s folder and create a file named .htaccess.
  2. Open it with Edit.
  3. If the file already has other rules of yours (redirects, security, caching), don’t delete them. Replace only the section between # BEGIN WordPress and # END WordPress, or add the block above without touching the rest.
  4. Save and open an inner page of the site.
  5. Go back to Settings > Permalinks and save again, so WordPress checks the file.

If WordPress is installed in a subfolder, for example yourdomain.com/blog/, the file goes inside that subfolder, and the lines RewriteBase / and RewriteRule . /index.php [L] must point to it (RewriteBase /blog/ and RewriteRule . /blog/index.php [L]). On a multisite installation, the rules are different from the ones above, and the safest approach is to copy them from the network admin dashboard or from a backup. For more details about the file, see .htaccess in WordPress: how to find and create the default file.

Step 4: if you still get 404 errors, look into other causes

With a correct .htaccess, the general 404 error usually goes away. If it persists, check:

  • Wrong site address. In Settings > General, check whether the “WordPress Address” and “Site Address” are correct, with the domain and protocol (https) you use.
  • Folder or domain change. After moving the site, the RewriteBase rules and the path to index.php must match the new folder.
  • Security, cache or redirect plugin. These can write to the .htaccess or create their own rules. Disable them one at a time by renaming the plugin’s folder in wp-content/plugins, and test. If the site uses cache, clear it: see what a caching plugin is for in WordPress.
  • Rules with no effect on the server. For the .htaccess to work, the server needs mod_rewrite enabled and must allow the file to override settings. If your panel or server doesn’t apply .htaccess (for example, if the site runs on a server that doesn’t use Apache), the configuration is done outside the file, and hosting support needs to help.
  • Custom content type. If only the items from a plugin (store, portfolio, events) return 404 errors, save the permalinks again after activating or updating that plugin.

In Settings > Permalinks, the Plain option uses addresses such as yourdomain.com/?p=123, which don’t depend on rewrite rules. It takes the site out of the 404 error, but it makes the addresses ugly and changes all the URLs that Google and other sites already know. Use it only as a temporary measure, and switch back to a structure with the post name, such as Post name, once the .htaccess is correct.

After the pages come back

  1. Open a few pages, posts and categories to confirm they load.
  2. Make a copy of the working .htaccess and keep it with the site’s backup.
  3. If you’ve just migrated the site, follow the steps in how to migrate a WordPress site to MigraCloud so you don’t lose other hidden files.
  4. If the problem will keep happening after every update, follow how to update WordPress, themes and plugins safely.

If, even with the right file, the pages still return 404 errors, hosting support can check whether address rewriting is enabled on the server. MigraCloud support is available here.

Frequently asked questions

Why does only my WordPress homepage load?

Because the homepage doesn’t depend on address rewriting, while inner pages do. If the .htaccess is missing or lacks the WordPress rules, the server can’t find a file for each address and returns a 404 error. Saving the permalinks again usually recreates the rules.

Go to the dashboard, open Settings > Permalinks and click Save Changes without changing anything. WordPress rewrites the rules and tries to update the .htaccess. If it doesn’t have write permission for the file, the dashboard will warn you, and you’ll need to paste the rules in by hand.

Where is the WordPress .htaccess file in cPanel?

In the same folder as wp-config.php, which on a main domain is usually public_html. Because its name starts with a dot, it only appears in the File Manager if you check Show Hidden Files in the settings.

Can I delete the .htaccess so WordPress creates a new one?

Yes, as long as you download a copy first, because the file may contain your own redirect, security or cache rules. After renaming or deleting it, save the permalinks again so WordPress rebuilds the default block, and then add your rules back one at a time.

I changed hosts and now the pages return 404 errors. What happened?

Most likely the .htaccess wasn’t copied, because hidden files are often left out of manual copies. Recreate the file with the default block and save the permalinks. If the site’s folder has changed, also adjust the RewriteBase.

Does the “Simple” option permanently fix 404 errors?

In practice it works, but it isn’t recommended as a permanent fix. It replaces the addresses with ?p=123, which hurts readability and changes the URLs that search engines already know. Use it only to take the site out of the 404 error, and switch back to a friendly structure after fixing the .htaccess.

Can a plugin cause 404 errors?

Yes. Security, cache and redirect plugins change the .htaccess or create their own rules. Disable them one at a time by renaming their folder in wp-content/plugins to find the culprit, and then save the permalinks again.

Can editing the .htaccess take my site down?

It can, if there’s an invalid rule: the result is usually a 500 error. That’s why you should download a copy before editing and change one thing at a time. If the site goes down, restore the copy or rename the file to test without it.

More on WordPress

See all →

Help center

Looking for something else?

See all tutorials, organized by topic.