How To Fix 404 Errors In WordPress

Posted by TotalDC

A 404 error in WordPress shows you that your browser can’t locate the page you are trying to access. Believe me, when you or your visitors are trying to access your website this can be super frustrating. While there is a chance that your page or post has gone missing, the majority of the time, this error has a different cause. In This article, you will learn how to deal with 404 errors in WordPress.

What Causes 404 Error Pages in WordPress

404 pages in WordPress are most often caused by the change in the permalink structure of your website. If you or another website owner changes the permalink structure of the WordPress website, they are going to end up with links pointing to pages that are no longer located at a particular address.

Other causes of 404 pages may indicate that you have some issues with the code in your index.php or search.php files. If there is an error in the code in these files, it may return results with invalid addresses.

When you are making changes to your index.php or search.php files, you must always make sure that all links from and to those pages are still working.

Why 404 Errors Matter In WordPress

First of all, 404 errors will impact your website’s user experience. More than that links with 404 errors is bad for your website’s SEO. When your website has many 404 links that are not fixed, Google will lower your SEO score, which means that your website will be harder to find on Google because 404 pages have a bad ranking value. And because of that overall ranking of your website is reduced.

How to Prevent 404 Errors In WordPress

First of all, set up your permalinks properly when you launch your website. You need to take the time when you first launch a website and set up your permalinks, then there is less chance that you will need to fix them in the future.

Second, do not delete your old content. If you have to take something down, rather than deleting it entirely, create a custom page at that address that provides some information on what used to be there, or links to other posts and pages that might be useful to the visitor of your WordPress website.

How to Fix 404 Errors In WordPress

Since a 404 error indicates a problem with your links, you can usually fix it by ensuring your permalinks are correctly configured and saved. You may also need to reset your linking structure using your .htaccess file.

Reset Your WordPress Permalinks To Fix 404 Errors

The first step to try is resetting your permalinks. Head to your WordPress dashboard and go to Settings – click on Permalinks.

how to locate permalinks position in wordpress dashboard

Then just click on Save Changes.

overview of permalink settings screen in wordpress

Clicking that button will update the permalink settings even if you don’t make any changes. With this done – reload the pages that were giving you a 404 error.

Restore .htaccess File To Fix 404 Errors

If resetting your permalinks did not work, the next strategy is restoring your .htaccess file. This controls how WordPress interacts with the server and how it generates permalinks for your website. Restoring it to the default settings can fix unexpected 404 errors.

To restore the .htaccess file, you need to access it. To do that you can use a Secure File Transfer Protocol (SFTP) client such as FileZilla.

In FileZilla locate and click on the folder that corresponds to your domain name. You will find the .htaccess file in this directory.

Then click on the .htaccess file and select Edit from the list of options. You can copy the current contents of the file and paste them on a separate file somewhere on your computer just in case you need to back up. Now replace the code in the .htaccess file with the following code:

# 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

This is the default .htaccess file for WordPress. When you have pasted this code in – save the file.

Restoring this file will also reset the permalink settings for your WordPress site. So if you’re using a custom permalink structure, you will need to restore that setting too.

To do so, go back to your WordPress dashboard and go to Settings – click Permalinks, make all necessary changes that you made before and simply press Save Changes.

Finally, refresh your website and attempt to load the pages that were returning 404 errors.

Disable All of Your WordPress Plugins and Theme To Fix 404 Errors

If you have reset your permalinks and .htaccess file, but you are still getting the 404 errors on your WordPress website, you have to check your plugins and theme. Plugins can have bugs or compatibility issues that are resulting in 404 errors.

Go to Plugins – click Installed Plugins.

how to locate installed plugins menu in wordpress dashboard

Disable your website plugins one by one and then check your website. If the 404 errors are still there, turn the plugin back on and move to the next one.

how to deactivate plugin in wordpress

If you get the error message after deactivating the first plugin, go back to the plugins screen, re-activate the plugin you just tried, and move to the next one in the list. If you find one that resolves the issue, you can check for updates that may resolve the problem or find another plugin with similar functionality to replace that plugin that keeps causing you problems.

If after disabling all plugins you still see the 404 error, it is worth changing your theme.

Go to Appearance – click Themes. Hover over one of the inactive themes and click on Activate. Then refresh your site and try to access the page or post that gave you the 404 error. If your theme is the reason for the troubles, that means that you will have to find a new theme that gives your website a similar look. Or if you have created that theme yourself then be prepared to spend some time working with your themes code to solve the problems.

Set Up A 301 Redirect For Moved Or Renamed Content In WordPress To Fix 404 Errors

If you do have content that is been moved or renamed and doesn’t exist anymore at the URL you were using previously, you will need to set up 301 redirects to point the old URL to the new one.

The easiest way to do this is with a WordPress plugin such as Redirection. This free plugin will let you quickly set up the redirects.