2

In my project, I'm routing all requests to index.php. Then I check $_SERVER['REQUEST_URI'] against a whitelist and display the relevent content.

Now, if the $_SERVER['REQUEST_URI'] does not match anything in my whitelist, I display some "page not found" text. In effect, it is a custom 404 error page.

My question is: do I need to write header('HTTP/1.0 404 Not Found'); before I output my HTML? What does it actually do? My error page is displayed regardless so is it important in this scenario?

Lars
  • 7,908
  • 11
  • 52
  • 70
  • 1
    If you're going to issue a 404 header then make sure that the page source is at least 512 bytes, otherwise IE's default settings will hide your page and display a "friendly" error. – Sammitch Feb 04 '13 at 15:58

1 Answers1

12

Yes. That header is used by search engines, and others, to know the status of a page and act accordingly. (e.g. remove that page from their index, etc)

John Conde
  • 217,595
  • 99
  • 455
  • 496