How to Fix the 404 Error for WordPress Websites

Posted on August 2, 2017 by in Tips & Tricks | 24 comments

How to Fix the 404 Error for WordPress Websites

‘404 errors’ are one of the most annoying parts of surfing the web. If you’ve ever run across one – and chances are you have – you’ll know how frustrating they can be. Therefore, quickly fixing them on your site is imperative (if they exist, of course).

Fortunately, WordPress enables you to tackle 404 errors using multiple methods, most of which are quite easy to implement. In this article, we’ll talk about what 404 errors are, explain how to detect broken links on your site, discuss creating a custom error page, and show you how to fix the problem using three different methods. We’ve got a lot of ground to cover, so let’s get started!

What the 404 Error for WordPress Is

‘404’ refers to the error code your browser displays when it can’t find what you’re looking for. Your browser will always look for the URL entered, regardless of whether it exists. If it doesn’t find anything, you’ll see an error:

A Chrome 404 error page.

Fortunately, this error is straightforward. You simply need to be mindful of any mistyped internal links in your content, and remove links to pages that no longer exist. It sounds like a hassle, but 404 errors can have serious negative repercussions, such as:

  • An increased bounce rate. Some people will leave your site immediately after running into this error, which will increase your bounce rate and affect your Search Engine Optimization (SEO).
  • It makes you look unprofessional. It’s safe to say that no one enjoys running into a ‘broken’ site. Even if the 404 error isn’t your fault per se, it can impact how your visitors perceive you.
  • They’re highly frustrating. In a lot of cases, your visitors might not be able to differentiate between your site being down and a 404 error. It means they might keep trying to access the same page and become frustrated.

The good news is minimizing the impact of 404 errors is simple. In fact, there are several ways to deal with them, but for now, let’s talk about prevention.

How to Detect Broken Links on Your WordPress Website

In general terms, any link that doesn’t work as it should is referred to as ‘broken’. Over the course of your site’s life, some links may stop working, but checking each of them manually is a fool’s errand. Enter the Broken Link Checker plugin:

The Broken Link Checker plugin.

This tool enables you to automate the process of checking the internal and external links on your site to identify any broken ones. If it finds one, the plugin will let you know so you can jump in and fix it.

Once you’ve installed and activated the plugin, it’ll run the first full check automatically, and you’ll be able to see the results on your dashboard’s home page:

The broken links widget on your dashboard.

By default, the plugin will check for any broken links every 72 hours, but you can tweak this value via the Settings > Link Checker page on your WordPress dashboard. As far as we’re concerned, running the test this frequently is overkill, but it shouldn’t have a noticeable impact on your site’s performance – so it’s up to you whether to tweak the value or not.

How to Create a Custom 404 Error Page for WordPress

A good 404 error page should be informative and look good.

One of the biggest problems with default 404 error pages is that most of them don’t give you enough information. If you’re somewhat tech-minded, you’ll probably take the time to read through your browser’s error description, but most people probably don’t. What’s more, for the visitor, seeing a string of text and the word “Error” sets alarm bells ringing.

Creating a custom 404 error page solves this problem, and many look to get creative with their layouts. In short, you don’t have to settle for an ugly, default error page – in fact, WordPress makes it relatively straightforward for you to customize yours. The goal here isn’t just to make your 404 error pages look pretty; you also want to take the opportunity to be informative. Take another look at our example at the beginning of this section. It clearly shows that the site is still working and explains what the problem is in layman’s terms.

The WordPress Codex has an entry on how to create a 404 page, but if you’re a Divi user, we’ve previously covered how to do this specifically for the theme. There are a number of steps, but Divi’s module system can make short work of it since there won’t be too many elements to include.

Finally, keep in mind that creating a custom 404 error page isn’t a fix per se. It’s just a way to lessen the negative impact when this issue pops up. With that in mind, let’s talk about some fixes.

How to Fix the 404 Error for WordPress Websites (In 3 Different Ways)

In this section, we’re going to walk you through three fixes for 404 errors. The first is a good option if you want to avoid 404 errors altogether, while the other two are more suited for troubleshooting purposes. Either way, we recommend you read through all three ways to find a solution that suits your needs.

1. Use a Plugin to Redirect 404 Errors

A ‘redirect’ is when you take a user visiting one URL, and send them to another one automatically. Your goal is to redirect anyone visiting a non-existing page on your site to another one (such as your home page, for example).

To do this, you’ll want to use a plugin such as Redirection, which is massively popular thanks to its ease of use:

The Redirection plugin.

Once you’ve installed and activated the plugin, head to the Tools > Redirection tab on your WordPress dashboard. Inside, you’ll find a list of all your existing redirects – which should be empty – and an option to set up new ones:

Setting up a new redirect.

The Source URL is the address that would lead someone to a 404 error, and the Target URL is the page you want them to land on. As we said earlier, your home page is your best bet. As for the other settings, we can safely leave them at their default values. However, there’s still the matter of which URLs you need to redirect.

The Redirection plugin will start to log any 404 errors that pop up for your visitors upon activation. You can access this data at any time by clicking on the 404 tab within the plugin’s settings:

Your 404 error logs.

You’ll want to check this tab periodically, grab the URLs giving your visitors trouble, and set up redirects for them. While it may be time-consuming initially, once you set up a redirect you’ll never need to worry about the URL again – so it’s worth the effort.

2. Fix Your Permalink Settings Manually

In some cases, your WordPress website might start showing 404 errors when anyone tries to access your posts. It doesn’t mean your posts were deleted, and in fact, it’s a somewhat common bug relating to your permalink structure (i.e. the format of your URLs).

The good news is that fixing this issue is a walk in the park (in most cases). Firstly, head to your WordPress dashboard, and navigate to the Settings > Permalinks tab:

Updating your permalink structure.

Here, scroll to the bottom and click on the Save Changes button without making any modifications to your settings. What this does is tell WordPress to save a new .htaccess file, which governs your permalink settings. Try to access your posts now, and if they’re still not working, move on to the third and last method.

3. Edit Your .htaccess File Manually

In most cases, if updating your .htaccess file via the WordPress dashboard doesn’t work, it’s due to a permissions error on your back end. It means you’ll need to get back there and make the changes manually, which is easier than it sounds.

To do this, you’ll need to use an FTP client – we recommend FileZilla – and access your website using the credentials your web host gave you. Once you’re in, access your WordPress root folder – it’s usually named either public_html, www, or after your site.

As we mentioned earlier, the file we’re looking for is called .htaccess. Before you continue, make sure you right-click the file and select Download. This gives you a way back if you make a mistake. When you’re ready, choose the View/Edit option:

Opening your .htaccess file.

This will open the file using your default text editor – you’ll want to delete the contents and replace it with WordPress’ default settings:

# 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

Now save your changes and try re-accessing your posts. They should be working, although you may have to go back to the Permalinks tab in WordPress and re-configure your URL structure to get it back to the way it was before.

Conclusion

Dealing with 404 errors is vital for many reasons, but so is preparing for them. While creating a custom 404 page is a good first step, you’ll also want to eradicate broken links using a solution such as the Broken Link Checker plugin. These measures are necessary if you want to make a good impression on your users, and protect your search rankings.

In this piece, we’ve looked at three methods for dealing with 404 errors in WordPress. Let’s recap them quickly:

  1. Use a plugin to redirect 404 errors.
  2. Fix your permalink settings manually.
  3. Edit your .htaccess file manually.

Do you have any questions about how to fix the 404 error for WordPress? Ask away in the comments section below!

Article thumbnail image by VikiVector / shutterstock.com.

24 Comments

  1. Thank you very much for this useful information.
    Great !!

    • John Hughes

      You’re welcome! 🙂

  2. I hope we’ll be able to create custom 404 pages with Divi in future)

  3. John,

    Thanks for a most comprehensive article. Thanks, too, for the links to examples of good 404 page design, and to the previous article ‘Creating Custom WordPress 404 Error Pages’- between them, you’ve cover all the bases.

    I believe that including your standard header/navigation/search and footers to frame the 404 message and graphic, serves to make the first-time visitor more at home. They can see straight away how they can navigate towards the information they want. I’d appreciate your thoughts on this.

    Cheers,

    John

    • John Hughes

      Hi John, thanks for your input! Your point about keeping important elements of your site consistent even on your 404 pages is a solid idea. 🙂

  4. Hey John,

    Thanks for the informative article. I am using this WP plugin for handling redirection.
    “Forty Four – 404 Plugin for WordPress – https://wordpress.org/plugins/forty-four/

    It generates a log of 404-page errors and suggests a redirect, or you may manually add a redirect page.

    Addition to that this light weight plugin also creates a custom 404 page which can also be customized by the user. What you think..???

    • John Hughes

      Hi Saurabh! We’re not familiar with that plugin, but it seems like a decent choice (although it hasn’t been updated in some time, which always means you should proceed with some caution).

  5. Most of time I prefer to install 404 WP plugins to fix such issue. And redirect them to either homepage OR appropriate webpages.

    • John Hughes

      Hi Anthony, thanks for your comment! There are definitely plenty of useful 404-related plugins out there to choose from. 🙂

  6. WordPress one of the best online Blogging platform but sometimes people face some issue with WordPress 404 Error, Internal Server Error & some another but each issue has a solution.

    Your suggestions and solutions are valid.

    I am Glad to read this post.

    • John Hughes

      Thanks! We’re glad you found this post so useful. 🙂

  7. Only this week this error occurred in two blogs of mine, glad that I went to research about it and found this matter enlightening and comprehensive, thank you

    • John Hughes

      You’re welcome! We hope you were able to fix the errors. 🙂

  8. Excellent advice thanks.

    • John Hughes

      Hi George! You’re welcome 🙂

  9. Hi

    If I am having many 404 urls and if I mark them as fixed the option which shows in google webmasters so is it fine to do this.

    • John Hughes

      Hi! It’s hard to say without knowing your exact setup. We’d recommend visiting the support website for the Google Webmaster tools to get more help: https://support.google.com/webmasters/.

  10. I think you missed one very simple solution. Instead of hassling around with .htacces etc., just create a page “404.php” in the themes-directory and you are done!

    Mine is like this:



    So it behaves like a standard webpage, keeps the layout and the content is added via the shortcode, injecting a library-item…

    this is far better than editing .htaccess etc.

    And bytheway: “Broken Link Checker” is one of the most problematic performance-killer-plugins ever…

  11. Thanks! I got an email from google about 404 errors. What I don’t understand is that the broken link checker didn’t find any… And there were 18 of them in the 404 tab of the redirection plugin while there were 25 in the google console.
    I fixed them but most of them were links from plugins or mywebsite.com/post/feed” with the “feed” at the end. Where does it come from? Thanks!

    • John Hughes

      Hi Laura; you’re welcome! It’s hard to say what the problem is without seeing your exact setup, but try posting the details in our forums (https://www.elegantthemes.com/forum/) to see if another user can help.

    • John Hughes

      Hi Arman, thanks for your comment! 🙂

576,027 Customers Are Already Building Amazing Websites With Divi. Join The Most Empowered WordPress Community On The Web

We offer a 30 Day Money Back Guarantee, so joining is Risk-Free!

Sign Up Today

Pin It on Pinterest