Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Pb headers

    Hi,

    On my page index.php (which is the default error page of my website), i
    eventually show an error message which comes from the analysis of those
    variables

    // Code >>
    $url_erreur = $_SERVER["REQUEST_URI"];
    $serveur_erreur = $_SERVER["REDIRECT_STATUS"];
    // << Code

    On another page, i eventually redirect to my homepage if the parameters
    are incorrect (this "another page" generate news and the output format
    is in the parameters)

    // Code >>
    $mode = $_GET ["mode"];
    if (($mode != "rss") && ($mode != "atom"))
    {
    // Redirect to index with error 404
    header("HTTP/1.1 404 Not Found");
    header("Location: http://localhost/me/");
    }
    // << Code

    Problem : the error code 404 sent does not affect the server variables
    and so there is no error message shown by index.php.

    How could i do ?

    TIA

    PS : Please apologize my poor english ;-)
    Nobody Guest

  2. Similar Questions and Discussions

    1. Please help me to set my headers and footers
      I have to use these settings for my books. Margin In Inches Book Size In Inches 5-1/2 x 8-1/2 Top/0.7 Bottom/3.2 Left/2.25 Right/2.25...
    2. Headers already sent?
      Hello. I just wondered if anyone has experienced this error before? "Warning: Cannot modify header information - headers already sent." ...
    3. Headers for ID CS?
      Is there a plug-in or a script for ID CS to do running phonebook style headers (like can be done in Pagemaker)? I have one job I've kept in PM...
    4. curl and sent headers
      is there any way of seeing exactly what headers cURL sent in a transfer, with PHP?
    5. [PHP] Please dirrect me -- headers ????
      Hi, Headers have nothing to do with the <head> tag, the headers are sent before the html page, ie they are not part of the html document, but...
  3. #2

    Default Re: Pb headers

    On Fri, 01 Oct 2004 23:01:14 +0200, Nobody <nobody@nowhere.no> wrote:
    > // Redirect to index with error 404
    > header("HTTP/1.1 404 Not Found");
    [url]http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5[/url]

    404 - there is no resource available for this URI.
    > header("Location: http://localhost/me/");
    Location means the resource exists, but is elsewhere, as indicated by the
    absolute URL. (at least for 3xx responses anyway).

    [url]http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30[/url]

    Surely a 4xx status and a Location header are mutually exclusive?

    --
    Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
    Andy Hassall Guest

  4. #3

    Default Re: Pb headers

    Andy Hassall wrote:
    > On Fri, 01 Oct 2004 23:01:14 +0200, Nobody <nobody@nowhere.no> wrote:
    >
    >
    >> // Redirect to index with error 404
    >> header("HTTP/1.1 404 Not Found");
    >
    >
    > [url]http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5[/url]
    >
    > 404 - there is no resource available for this URI.
    >
    >
    >> header("Location: http://localhost/me/");
    >
    >
    > Location means the resource exists, but is elsewhere, as indicated by the
    > absolute URL. (at least for 3xx responses anyway).
    >
    > [url]http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30[/url]
    >
    > Surely a 4xx status and a Location header are mutually exclusive?
    >
    Quote >
    The Location response-header field is used to redirect the recipient
    to a location other than the Request-URI for completion of the request
    or identification of a new resource.
    < Quote

    It is not said that the resource should exist. It is said "for
    completion of the request or identification of a new resource". In my
    opinion, it is correct to send a 404 error to indicate the resource
    asked for does not exist, then to redirect the user elsewhere in order
    to give him "a new resource" to look at, this resource explaining (via
    an explicit message) the kind of problem encountered.

    But my problem is not here. If i understood well, the 404 error
    generated does not affect the server, it is simply sent to the client.
    Opposite to the use of errorDocument.

    So how sould i do to get the 404 code in my index.php ?
    Nobody Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139