skip to Main Content

I am using SiteChecker.Pro to check my website for seo errors and it tells me this:
4xx client errors
The explanation is that when a visitor hit a non-existent page, my scripts site-wide are doing a JS redirect to a custom 404 page (which in fact has 200 status code).
What is the best strategy to return a custom page with a content but with 404 status code in the header?

2

Answers


  1. Why Sitechecker reported this as an issue.
    In terms of SEO it is important to avoid a situation where same content is returned to search bots under different URLs. This is to avoid duplication of content, as users don’t want to see same pages in the search results. Returning a 404 status code for non-existing pages tells bots that the content in the page should not be crawled or indexed. If you, however, return a 200 status code in server headers, your content can be indexed and then regarded as duplicate.

    Login or Signup to reply.
  2. You can use PHP to give a 404 error using:

    <?php
    http_response_code(404);
    ?>
    

    (See: PHP http_response_code() Function)

    Some hosting options will also work with a 404.html file in the root, but not always.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search