How to Fix WordPress 404 Errors: Pages Not Found After Changing Permalinks

How to Fix WordPress 404 Errors: Pages Not Found After Changing Permalinks

A change in the WordPress permalinks structure may help you create clean URL addresses that would also be good for search engine optimization, but there is one thing you should be ready for after this operation – your site will function normally, but some of the posts and pages will start returning the 404 Not Found error.

It occurs because of the fact that WordPress has updated its URL generation procedure, but the rewrite rules for redirecting users to the right page have not been updated.

This article will walk you through fixing WordPress 404 errors after permalinks change, as well as what to do if the permalinks solution doesn’t work.

 

Why Do WordPress Pages Have 404 Error When You Change the Permalinks?

The WordPress website uses the permalink structure to decide how pages will appear in URLs.

For instance, an example could be when the URL structure changes from:

example.com/?p=123

to:

example.com/my-blog-post/

This content is still present in the WordPress database; however, the web server has to be taught how to handle this new URL and forward the request to WordPress. If these rewrite rules are not done properly, the server won’t know where to look for the page and will give out an error message.

Some common reasons are:

  • Permalink structure is not reset
  • .htaccess file is either missing or corrupt
  • Rules for rewrite in Apache are not working
  • Plugin is affecting URLs
  • There are conflicting rewrite rules in a theme
  • URLs of pages/posts have been altered
  • Old URLs lack redirects
  • Incorrect WordPress URL settings
  • Server setup does not support selected permalink structure

Our guide on fixing 404 errors in WordPress posts and page also mentions bad permalinks and .htaccess settings as a possible cause.

WordPress Fixes for 404 Page Errors

1. Again, Save Your Permalink Settings

This should always be your first course of action because it is quick and does not involve file manipulation.

How to Save Permalinks Settings

  • Login to your WordPress Dashboard
  • Look for the menu on the left-hand side of the screen
  • Go to the Settings section
  • Go to Permalinks
  • Select your favorite URL settings or select Custom
  • Scroll all the way down to the bottom of the page
  • Click the Save Changes button

Now try opening any of the posts/pages for which you got a 404 before. If they open up fine, it is probably because your permalink rules were outdated.

Why does this happen?

Once the changes are saved in the permalink settings, WordPress recreates the rewrite rules that will convert the friendly URLs to WordPress calls.

This comes in handy especially after:

  • Modification of the permalinks structure
  • Website migration
  • Backup restoration
  • Installation of specific plugins
  • Server modifications

Permalink structure is also recommended to be refreshed as part of WordPress troubleshooting guidelines.

2. Find Out If the Error is Consistent Across All Pages

Just because all 404s look the same does not mean they have the same cause.

Experiment with different kinds of URLs:

  • Home page
  • Blog post
  • Regular page
  • Tag archive
  • Custom post type (if relevant)
  • Category archive

If one page displays 404 error, then the issue is probably with the particular URL, slug, redirect, or content of the page.

If all the posts or pages are 404ing except for the homepage, then permalink settings are probably involved. This differentiation can save you time in changing the whole website unnecessarily.

3. Check for the .htaccess File

In case you fail to sort out the issue by saving the settings of the permalinks, check your .htaccess file.

On Apache and LiteSpeed web servers, the .htaccess file may have some rewrite rules that will allow WordPress to read the friendly URLs properly.

Note: If the file is present but seems to be causing trouble, do not just remove it. First download a backup and see what it contains.

To examine and view your .htaccess file, here is how you should do it:

  • Login directly to your HarmonWeb Client Area.
  • Go to and login to your cPanel account.
  • Locate the Files tab on your cPanel Dashboard.
  • Click on File Manager.
  • Save your settings.
  • At the top right side of the File Manager screen, click Settings.
  • Click the Show Hidden Files (dotfiles) option in the popped-up window.
  • In the left folder directory structure, click your site’s main website folder—normally public_html.
  • Browse the list of files for the .htaccess file.
  • If you wish to edit the file’s contents, you should right-click it and choose Edit or Code Edit from the options that appear.

However, if you do not see the file even after making visible the hidden files, then it is clear that the file has not been created yet.

  • Go to the upper left-hand corner of the File Manager where you will find the +File icon.
  • Call the file .htaccess (do not forget about the leading dot).
  • Click on “Create New File”.

In case you are using WordPress, then to create a clean file automatically, go to the WordPress settings, click on “Permalinks”, and hit Save Changes.

4. Checking your WordPress URL Settings

Wrong WordPress URLs not only create redirect issues but can also affect request processing by WordPress. You can find out your URL settings for WordPress by checking your WordPress Admin Dashboard settings or through cPanel phpMyAdmin in case you are unable to access your site.

A. Using the WordPress Dashboard (The Easiest Method)

If you are able to access your website normally, then here are the steps you need to take:

  • Access your WordPress Admin Dashboard.
  • Click on Settings > General from the left-hand sidebar menu.
  • Look for the WordPress Address (URL) and Site Address (URL) options.
  • Make sure both are same and display your proper domain name (make sure that it has “https://” in case your SSL is enabled).
  • Save the settings.

B. Using cPanel phpMyAdmin (Database)

  • Go to cPanel and select phpMyAdmin under Databases.
  • Select the database for your WordPress site from the left hand menu.
  • Select wp_options table (Please note that you may have some other prefix for your database such as wpxx_options).
  • Locate the siteurl and home entries under the option_name column.
  • Look at their values under the option_value column.
  • You can edit their text by clicking on them.

This test is very crucial for websites that have been recently migrated, undergone domain changes, or have SSL enabled.

5. Do Not Redirect All 404s to the Homepage

It is a very common misconception to send all non-existent links to the homepage. While this might technically reduce the number of 404 pages that appear to be visible, this is certainly not a good approach.

For instance, if you had content in /old-product/ which is now replaced with /new-product/, redirect the first one to the second URL. In the absence of a proper substitute, a proper 404 response for the URL can be issued.

6. Clear Your Caches

The caching process may occasionally lead to confusion during debugging as you will keep getting the old response even when the issue is fixed.

Clear:

  • Browser cache
  • Cache from WordPress caching plugin
  • Server cache
  • CDN cache, if any

The affected URL should then be tested using a private browser window.

Should the website use any CDN/proxy service, temporarily testing the origin server may prove useful in figuring out if the 404 is thrown by WordPress or something before it.

7. Plugin Conflict Problem

A WordPress plugin might make changes to URLs, redirects, rewrite rules, caching, security settings, or custom post types.

If you had just installed a plugin and encountered the 404 error right away, try disabling the plugin. If you have access to the dashboard, enter:

Plugins > Installed Plugins > Deactivate

If you do not have access to the WordPress Dashboard, you can access it through File Manager/FTP.

Navigate to:

wp-content/plugins/

Rename the plugins folder temporarily, such as:

plugins-disabled

Then test your website.

When 404 errors no longer appear, rename the folder back and activate the plugins one at a time in order to isolate the plugin causing the problem. This trick can be helpful when trying to fix other issues on WordPress fix other issues on WordPress as well.

What if Google has indexed the old URLs?

In case your permalink structure has been changed, Google may already have indexed those old URLs. Don’t get worried about those 404 URLs that Search Console is reporting. First find out whether the old URL has a replacement or not. If it has, do a 301 301 redirect to the new URL.

Setting up a 301 redirect via cPanel:

  • You will have to log in to the Client Area or cPanel panel.
  • Find the Domains category in the cPanel and click on Redirects.
  • Then choose the Permanent (301) option under Add Redirect.
  • Select the particular domain/sub-domain you wish to redirect from the https?://(www.)? dropdown menu.
  • Type the URL you wish to redirect to in the Redirects to text box.
  • Press the Add button to activate your permanent redirect.

However, if it doesn’t have a replacement, a 404 error might be the way to go.

How to Avoid Permalink 404 Errors in the Future

Before you alter your permalink settings:

  • Create a backup of your site.
  • Note down any existing URLs.
  • Check all your internal links.
  • Redirect URLs that require redirecting.
  • Run the new permalink setup on vital pages.
  • Avoid making changes in your URL structure unnecessarily.

In case you are making extensive changes to your live site, testing these in your staging environment is advised, as it may save you from broken links. HarmonWeb’s WordPress site troubleshooting checklist includes backups and troubleshooting prior to making major changes.

Conclusion

WordPress 404 errors following changes in permalinks are normally due to faulty or outdated rewrite rules, not missing content.

Go first to Settings > Permalinks and click on Save Changes. If this does not solve the problem, proceed to check .htaccess, WordPress URL settings, plugins, redirections, cache and server configurations.

Still Receiving 404 Error Pages Post Change in Permalink Settings?

In case you have made sure of changing the permalink settings and even reviewed the WordPress settings but you are still unable to visit valid web pages, then there might be an issue pertaining to the server rewrite rules, .htaccess, PHP, cache or host settings.

In case you require assistance in solving the server level WordPress issues, get in touch with your hosting company for support. If you are looking for a hosting service with regard to WordPress, you should consider WordPress hosting services offered by HarmonWeb.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply