Thread: Headers

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    i just installed apache 1.3.9 with php4 and was wondering how i can make it so that header function works... Well like the following gives me a server misconfiguration error:

    header('WWW-Authenticate: Basic realm="Top 10 Login"');
    header('HTTP/1.0 401 Unauthorized');
    printf('Authorization required...');

    can anyone PLEASE tell me where i can enable or tweak apahce so that the previous code would work..

    also.. how i can setup custom error pages like 500 and stuff

    thanks in advance!
    Cisk
    devcisk@ev1.net

    ------------------
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    3
    Rep Power
    0
    ahh, could somebody answer this question please. I have the same problem :

    I'm getting 500 errors (Internal Server Errors), when i'm working with headers.

    i suppose it's something in the apache conf file, that has to be turned off/on, but i'm not sure what.
  4. #3
  5. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Assuming your server allows you to override "FileInfo" (you probably can if you are allowed to use .htaccess), you can then put this line in your .htaccess file:
    ErrorDocument 500 /500.html

    Place this 500.html and .htaccess files in your root directory in this case.

    Go to http://www.apache.org/docs/mod/core.html#errordocument to find out more..
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    3
    Rep Power
    0
    what i mean is when i, for example, use this script (copied from php.net) on my localhost

    <?
    if (!isset($PHP_AUTH_USER)) {

    // If empty, send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="My Private Stuff"');
    header('HTTP/1.0 401 "Unauthorized"');

    echo 'Authorization Required.';
    exit;
    }

    // If not empty, display values for variables

    else {

    echo "
    <P>You have entered this username: $PHP_AUTH_USER<br>
    You have entered this password: $PHP_AUTH_PW<br>
    The authorization type is: $PHP_AUTH_TYPE</p>
    ";

    }

    ?>


    i get an 500 error.
    in my error.log i then find the following line:


    [Thu Apr 20 22:34:02 2000] [error] [client 127.0.0.1] malformed header from script. Bad header=HTTP/1.0 401 "Unauthorized": c:/php/php.exe


    What's going on here?

  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    1
    Rep Power
    0
    Cisk,
    Just wondering what platform you had installed apache and PHP under, becuase I had a similar problem. The header function dosen't seem to work the way that you have it written out under the windows environment, but I've found a statement that seems to work instead ...


    Header ( "WWW-authenticate: basic realm=Restricted Area");

    Header ( "Status: 401 Unauthorized");

    echo "<meta http-equiv="refresh"
    content="0;url=index.php">";

    exit;


    I really don't know about setting up custom error pages though ...

    darkray77
    voltron@notes.udayton.edu


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by devCisk:
    i just installed apache 1.3.9 with php4 and was wondering how i can make it so that header function works... Well like the following gives me a server misconfiguration error:

    header('WWW-Authenticate: Basic realm="Top 10 Login"');
    header('HTTP/1.0 401 Unauthorized');
    printf('Authorization required...');

    can anyone PLEASE tell me where i can enable or tweak apahce so that the previous code would work..

    also.. how i can setup custom error pages like 500 and stuff

    thanks in advance!
    Cisk
    devcisk@ev1.net

    [/quote]


IMN logo majestic logo threadwatch logo seochat tools logo