How to Fix Soft 404 Errors on WordPress

By November 6, 2017June 9th, 2020SEO, Web Design

Soft 404 errors can be quite common on WordPress websites and it is something that needs to be addressed to not confuse the search engines and help your overall site health and rankings.

In this tutorial, we will teach you how to fix Soft 404 errors on WordPress, this should also work on non-WordPress websites, depending on the type of website and setup you have.

Before we start, let’s learn what Soft 404 errors are and how different they are from Hard 404s.

 

What is the difference between Hard 404 and Soft 404?

Hard 404

When a visitor clicks on a link on your website that does not exist anymore, your website usually reacts by displaying a custom “404 page not found” error, and returning a 404 HTTP response to show the content is no longer there.

Hard 404 error

This is Hard 404 and it is normal.

It basically tells the content no longer exists or has been moved. The search engines have no issue with this.

Watch this quick Google video on how to properly deal with Hard 404s and follow the advice/solution John Mueller gives.

Google 404 error pages, video

You can also read our guide on HTTP Status Codes to learn more about 404 and other errors and how they affect your SEO.

Soft 404

A Soft 404 error happens when a page has no content but the website does not return a 404 HTTP response for the page.

While Soft 404 errors don’t usually interfere with the user experience greatly, they can hamper your site’s search rankings.

Pro Tip: If you have published new content on a different section of your website and it is still relevant to the old page that has been removed, it is always a good idea to 301 redirect the old page to the new one to not lose link juice.

Understanding Soft 404 Errors

The most common cause of a Soft 404 error is when a user is searching for a query on a site’s internal search engine, that does not exist.

Let’s say that you have a blog and it is about Graphic Design. So, for example, if I go to your page and I search for something that doesn’t exist on your page, it will return an error “No match” or “Not found”.

If the server response code is 200OK, this means you have a Soft 404 error.

Soft 404 Error

You will know this because the server response code should say, 404 Not Found when something does not exist on your site.

The other possible reason is that you have a category or tag that doesn’t have any content under the category.

So, when someone clicks on your link, there is nowhere for them to be lead to.

This will also lead to the Soft 404 error if the server response code is 200 OK.

How do I check my site for Soft 404 errors?

Google Search Console is the best place to find these errors. Login to your Search Console and go to Coverage reports.

The Coverage report shows all the issues with your site including Soft 404.

Google Search Console Soft 404 error

If you click on the Soft 404 error link, it will give you more details and list all the errors as you can see in the screenshot below.

Google Search Console Soft 404 error example

If your search query error looks a little bit different then from the example shown above, it is okay. This tutorial will still work!

So, what do all these mean?

If you see all these random characters like /?s= and the /search/ this means your website’s internal search engine is returning a Soft 404 error because the content the user types on your site’s search engine does not exist.

Before we fix the Soft 404 errors let’s confirm these errors using Google Chrome Developer Tools.

Confirming the errors

To confirm these errors, copy the error code from your Search Console and past it at the end of your URL and click enter on your browser.

Example:

http://www.example.com/?s=%/7Bquery%7D
Soft 404 example

After this, click View on Google Chrome menu and navigate to Developers > Developer Tools.

Chrome developer tools

Then click on the Network tab on the Developer Tools and reload the page.

This will reload all the network activity on your page and list all the requests with their status codes.

Fix Soft 404 error

Notice how this URL “http://www.example.com/?s=%/7Bquery%7D” says status 200 OK?

This is how the browser is tricking the search engines and it is the reason why we see the Soft 404 error in the Google Search Console.

The status should be 404 Not Found because this page does not exist. It is a non-existing search query.

Ok, now the fun part! Let’s start fixing these Soft 404 errors.

Solution 1:

Blocking search engine access to the website’s internal search functionality

This is the easiest solution and works well.

What we will do is block the search engines from accessing our website’s search results.

Note that this will not affect your website’s indexing or ranking, we will just block the internal search results.

All you have to do is to put this code in your robots.txt file and upload it to your server.

User-agent: *
Disallow: /?s=
Disallow: /search/

Please note:

  1. If you already have “User-agent: *” in your robotst.txt file, do not past this line of code.
  2. If you are using any cache plugins, make sure to clear the cache before checking.

Allow Google a few days to update this fix on Google Search Console.

Sometimes Google is slow displaying the updated information on the Search Console. If it is taking too long, follow this guide to upload your updated robots.txt file and submit to Google.

Solution 1:

Blocking search.php file to fix Soft 404 errors on WordPress

Most WordPress themes should have a search.php file, find that file and paste this code in there.

if ('{query}' == get_search_query( false )){
header( 'HTTP/1.0 404 Not Found' );
$GLOBALS['wp_query']->is_404 = TRUE;
get_template_part('404');
die();
}

Save and upload it to your server. Make sure you keep the backup of your original search.php file just in case something goes wrong, you have the original back up of the file.

Again, if you are using a cache plugin, remember to clear the cache after you upload the changes to the server.

Now, to check and confirm everything is working properly go back to Google Chrome and reload the page again and check your Network tab.

If the 200OK is changed to 404 Not Found the code does its job!

Fix Soft 404 error

When the search engines re-crawl your website again, they will notice the changes and your Soft 404 issue will be gone.

If you know any other methods on how to fix Soft 404 errors, we’d love to hear them in the comments!

2 Comments

  • karan says:

    Hello, Can you tell me what is better for SEO, it is good to point all your soft 404 pages to the home page or create a relevant article for 404 pages?

    • Amberd says:

      Are you talking about Soft 404 or Hard 404? I think you meant to say Hard 404 (or just simply 404), the Soft 404 is very different from the Hard and its explained how to troubleshoot and fix in this article.

      You can do one of the following if you meant Hard 404:

      1. You can redirect old URLs to the new ones.
      2. You can create relevant and meaningful content for those 404s that have a lot of links pointing to them. This way you will get all that lost link juice back to your site.
      3. Leave as they are if you do not intend to create content, they are perfectly fine. The search engines will not penalize you for having 404s.

      Thank you!

Leave a Reply

1K Shares
Share
Tweet
Pin
Share
Share