How to Fix Soft 404 Errors on Most WordPress Themes

By 11/02/2017SEO, Web Design

Soft 404 errors can be quite common in most WordPress themes and it is something that needs to be addressed for your website to work properly.

Soft 404 vs Traditional 404 Error

When a visitor goes to your website and attempts to open a page that no longer exists, your website usually reacts by displaying a custom “404 page not found” page, and returning a 404 HTTP response to show the search engines that the content is no longer there. This is normal!

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, it can hamper your sites search rankings.

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 Landing Pages. 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”.

Search query

If the server response code is 200 OK, 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 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.

Finding the Errors in Your Pages

To find the errors in your code you need to do a little digging. First, you will want to Sign in to your Google Search Console, then click on the Crawl Errors, Soft 404 tab. Here you will find any errors on your sites listed in order of importance.

soft 404 error sample

If you have any Soft 404 errors, Google will display them here. Once you have the errors on your page isolated, you can check them by using Firefox or Chrome. For this example, we will use Firefox. To do so, 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

Firefox

After this, go to Tools > Web Developer > Inspector on Firefox. Once you do this you should see the Inspector open up at the bottom, like in the example below.

200 OK code

Notice at the side it says the status is 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’s Search Console. The status should be 404 Not Found because this page does not exist. It is a non-existing search query. Next, we will resolve this error so it is no longer plaguing your site.

Fixing the Error

If your search query error looks a little bit different then from the example shown here, it is okay. Whatever error code you see in your Search Console use that rather than the ones above.

Most WordPress themes should have search.php file, find that file and past 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.

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

Now go back to Firefox and repeat the testing process explained in “Finding the Errors in Your Pages” section above.

Hard 404 fix

Now you should see traditional 404 Not Found error instead of 200 OK! When the search engines re-crawl your website again, they will notice the changes and your Soft 404 issue will be gone.

Leave a Reply

Made In Los Angeles