404 header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GT

    404 header

    If I write a script like so:

    <?php
    header("HTTP/1.x 404 Not Found");
    ?>

    and run it through IE or FF why don't I get the browser's page not
    found message? I can see the header on liveheaders in FF but I don't get
    the 404 I expect in the browser.

    The whole script is to deliver rescaled jpegs, but I want a 404 if the
    parameters are wrong, or it can't open the file etc..

    Any help very much appreciated.

    --
    GT
  • BKDotCom

    #2
    Re: 404 header


    GT wrote:
    If I write a script like so:
    >
    <?php
    header("HTTP/1.x 404 Not Found");
    ?>
    >
    and run it through IE or FF why don't I get the browser's page not
    found message? I can see the header on liveheaders in FF but I don't get
    the 404 I expect in the browser.
    The browser doesn't create the error message, the server does.
    Usually, the default httpd error generated by apache or IIS
    You've essentially created a custom 404 error page.

    It's up to you to say "Page not found" or whatever.

    perhaps you actually want a 405 or 406?
    "Method Not Allowed" or "Not Acceptable"?

    Comment

    • GT

      #3
      Re: 404 header

      BKDotCom wrote:
      GT wrote:
      >If I write a script like so:
      >>
      ><?php
      >header("HTTP/1.x 404 Not Found");
      >?>
      >>
      >and run it through IE or FF why don't I get the browser's page not
      >found message? I can see the header on liveheaders in FF but I don't get
      >the 404 I expect in the browser.
      >
      The browser doesn't create the error message, the server does.
      Usually, the default httpd error generated by apache or IIS
      You've essentially created a custom 404 error page.
      >
      It's up to you to say "Page not found" or whatever.
      >
      perhaps you actually want a 405 or 406?
      "Method Not Allowed" or "Not Acceptable"?
      >
      Thanks,

      So (if I understand correctly) the reason I don't get any output would
      be because I haven't set up the Apache ErrorDocument to tell the server
      what to serve in the case of these errors?

      --
      GT

      Comment

      • BKDotCom

        #4
        Re: 404 header


        GT wrote:
        Thanks,
        >
        So (if I understand correctly) the reason I don't get any output would
        be because I haven't set up the Apache ErrorDocument to tell the server
        what to serve in the case of these errors?
        The reason you don't get any output is because you didn't output
        anything!
        You simply sent a header. At least with your example.
        try

        <?php
        header('HTTP/1.x 404 Not Found');
        echo 'Page Not Found!';
        ?>

        Comment

        • GT

          #5
          Re: 404 header

          BKDotCom wrote:
          GT wrote:
          >Thanks,
          >
          The reason you don't get any output is because you didn't output
          anything!
          You simply sent a header. At least with your example.
          try
          >
          <?php
          header('HTTP/1.x 404 Not Found');
          echo 'Page Not Found!';
          ?>
          I've been struggling with this! I think I was getting confused by the IE
          404 message, which was sometimes appearing when I sent the header, and
          sometimes not. That seems to be more reliable today - just a cacheing
          issue perhaps? Seems good enough now though. Thanks for the help.

          Comment

          Working...