Soft 404 errors can be quite common on WordPress websites, and they need to be addressed so as not to confuse the search engines and to help your overall site health and rankings.
This tutorial will teach you how to fix Soft 404 errors on WordPress. This should also work on non-WordPress websites, depending on your website type and setup.
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.
This is a 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 adequately dealing with Hard 404s and follow the advice/solution John Mueller gives.
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 significantly, they can hamper your site’s search rankings.
Understanding Soft 404 Errors
The most common cause of a Soft 404 error is when a user searches for a query that does not exist on a site’s internal search engine.
Let’s say that you have a blog and it is about Graphic Design. So, for example, if I go to your page and 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.
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 with no content under the category.
So, when someone clicks on your link, there is nowhere for them to be led 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.
If you click on the Soft 404 error link, it will give you more details and list all the errors, as shown in the screenshot below.
If your search query error looks slightly different from the example 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, past it at the end of your URL, and click enter on your browser.
Example:
http://www.example.com/?s=%/7Bquery%7D
After this, click View on the Google Chrome menu and navigate to Developers > 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.
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 put this code in your robots.txt file and upload it to your server.
User-agent: * Disallow: /?s= Disallow: /search/
Please note:
- If you already have “User-agent: *” in your robotst.txt file, do not paste this line of code.
- 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 to display the updated information on the Search Console. If it takes too long, follow this guide to upload your updated robots.txt file and submit it 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, reload the page again, and check your Network tab.
If the 200OK is changed to 404 Not Found, the code does its job!
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!