Professional Web Applications Themes

Pb headers - PHP Development

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 ysis 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 ...

  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 ysis 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. #2

    Default Re: Pb headers

    On Fri, 01 Oct 2004 23:01:14 +0200, Nobody <nobodynowhere.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 / <andyandyh.co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool
    Andy Hassall Guest

  3. #3

    Default Re: Pb headers

    Andy Hassall wrote:
    > On Fri, 01 Oct 2004 23:01:14 +0200, Nobody <nobodynowhere.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 errorDoent.

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

Similar Threads

  1. Http headers...
    By zperetz in forum ASP
    Replies: 0
    Last Post: July 20th, 03:31 PM
  2. Headers already sent?
    By John in forum PHP Development
    Replies: 3
    Last Post: November 18th, 01:24 AM
  3. Headers for ID CS?
    By Cyndee_Meystel@adobeforums.com in forum Adobe Indesign Windows
    Replies: 0
    Last Post: July 6th, 05:52 AM
  4. Section headersódid I do it right?
    By Andy_Fielding@adobeforums.com in forum Adobe Indesign Windows
    Replies: 0
    Last Post: June 27th, 10:26 AM
  5. Getting all http headers
    By Arthur in forum ASP.NET Web Services
    Replies: 2
    Last Post: August 4th, 07:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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