Hide Your Site From Search Engines by using PHP 404 Header Code

You are reading this article because you want a surefire way to prevent your PHP pages from being indexed on search engines.

In earlier days, you would add a robots.txt file to the website to tell google fro example not to index, however, google stopped recognising robots.txt noindex in 2019.

If you are using PHP and want to prevent pages being indexed, the best way is to return a "silent" 404 error.

The code below added to any page will return a 404 error so if a bot is scanning your pages, they will see a 404 error and ignore it.

#####################
// throw silent 404 error everytime so this page is never indexed
// https://www.jucra.com/whmcs/knowledgebase/169/
#####################
header("HTTP/1.0 404 Not Found");




  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Force download a file with PHP

This is a super helpful script if you need to force download a PHP file from another location on...