It is currently Thu Jun 21, 2018 2:40 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Server Responding With 200 Ok or 302 Found instead of 404
PostPosted: Wed Sep 09, 2009 7:47 pm 
Newbie
Newbie

Joined: Wed Aug 29, 2007 7:52 am
Posts: 27
McAfee Site Advisor tells me that my site responds to non-existent files with HTTP 200, and my own packet analysis shows the response to be 302 Found, redirected to my custom 404 page.

How can I configure my site to have a custom 404 page without the server responding with a 200 or 302 response?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 10, 2009 2:01 pm 
Support Tech
Support Tech

Joined: Fri Mar 24, 2006 7:21 pm
Posts: 842
Here is a complete tutorial on how you will be able to create and set a custom 404 Error Page for your site hosted with us.

Please, create a custom .htaccess file using your account File Manager/Create New File/Folder option. If you have an .htaccess file in your site structure pleaase add the following line to your .htaccess file:

ErrorDocument 404 /error404.php

.. and make sure your index.php returns 404 (as above). Also, DO NOT use static html pages for this -- you can't change the result code on a static html page.

If you find the following in your .htaccess file, remove it -- it's redirecting errors to your entry page:

ErrorDocument 404 /index.php

Again: DO NOT USE THIS LINE.
Adding result code 404 to a PHP page

Use this in PHP pages:

<?php
header("HTTP/1.0 404 Not Found");
?>

for more info: gsitecrawler.com/articles/error-404-200.asp

_________________
Best Regards,
Burton
ModeratorsTeam
Freehostia.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 16, 2009 8:12 am 
Newbie
Newbie

Joined: Wed Aug 29, 2007 7:52 am
Posts: 27
Thanks, I'll look at this in the morning after the coffee kicks in :-P


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 17, 2009 5:09 am 
Newbie
Newbie

Joined: Wed Aug 29, 2007 7:52 am
Posts: 27
Still not working.

Here is my .htaccess file:

Code:
ErrorDocument 404 /errors/404.php


The page /errors/404.php contains this at the top before the DTD declaration of the HTML:

Code:
<?php
   header("HTTP/1.0 404 Not Found");
?>


as suggested in the article you referenced.

A few things I've noticed:

If I specify an error document in the CPanel, then 404 errors get sent to that document, as expected, but send 302 responses instead of 404 to the client. If I do not specify an error page in CPanel but use a .htaccess file instead then all 404 errors go to https://cp.freehostia.com/404/ with a 302 response.

It seems as though Freehostia isn't honoring the .htaccess file directives.

When I directly request the /errors/404.php file (rather than enter an erroneous URL) then everything works the way I want it to. The server responds with a 404 header and the custom error page is displayed in the browser.

Packet capture, direct request to /errors/404.php:
Query:
Code:
No.     Time        Source                Destination           Protocol Info
      9 0.129165    192.168.1.149         66.40.52.73           HTTP     GET /errors/404.php HTTP/1.1
   Hypertext Transfer Protocol
    GET /errors/404.php HTTP/1.1\r\n
        [Expert Info (Chat/Sequence): GET /errors/404.php HTTP/1.1\r\n]
        Request Method: GET
        Request URI: /errors/404.php
        Request Version: HTTP/1.1
    Host: www.boredomsoft.org\r\n

Response:
Code:
No.     Time        Source                Destination           Protocol Info
     11 0.279743    66.40.52.73           192.168.1.149         HTTP     HTTP/1.1 404 Not Found  (text/html)

   Hypertext Transfer Protocol
    HTTP/1.1 404 Not Found\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 404 Not Found\r\n]
        Request Version: HTTP/1.1
        Response Code: 404
   Line-based text data: text/html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n
    <html xmlns="http://www.w3.org/1999/xhtml">\n
    <head>\n
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\n
    <title>404</title>\n
    <link rel="stylesheet" href="errors.css" type="text/css" />\n
    </head>\n
    <body bgcolor="#64748B">\n
    </head>\n
    \n
    <body>\n
    <p>&nbsp;</p>\n
    <p>&nbsp;</p>\n
    <p>&nbsp;</p>\n
    <p>&nbsp;</p>\n
    <table width="918" border="0" align="center">\n
      <tr>\n
        <td width="156" rowspan="4" class="bodyText"><img src="exclaimation.gif" width="151" height="151" /></td>\n
        <td class="bodyText"><span class="style5">HTTP Error 404: Inept or ham-handed user </span></td>\n
      </tr>\n
      <tr>\n
        <td width="903" bgcolor="#FFFFFF" class="bodyText"><ol>\n
            <strong>Emptiness</strong>:\n
    [truncated]         <li>The state of being empty; absence of contents; void space; vacuum; as, the emptiness of a vessel; emptiness of the stomach.</li><li>Want of solidity or substance; unsatisfactoriness; inability to satisfy desire; vac
            <li><strong>Want of knowledge; lack of sense; vacuity of mind</strong>.</li>\n
        </ol></p>    </td>\n
      </tr>\n
      <tr>\n
        <td bgcolor="#FFFFFF" class="style5"><div align="center">the page you asked for does not exist in our space-time continuum </div></td>\n
      </tr>\n
      <tr>\n
        <td bgcolor="#999999"><p><a href="javascript:history.go(-1)">Go back</a>, thee, from whence thou came. And darken not this URL again. For if thou dost not heed my words, then thou dost have the brain of birds. Amen </p>    </td>\n
      </tr>\n
    </table>\n
    <p align="center"><a href="http://www.boredomsoft.org">Go To Main Page </a></p>\n
    </body>\n
    </html>\n


Packet capture, requesting erroneous URL:
Query:
Code:
No.     Time        Source                Destination           Protocol Info
     20 5.876681    192.168.1.149         66.40.52.73           HTTP     GET /;fjdngskdjfng;lskdjfnglskdjfglskdjfgksjdfgn HTTP/1.1
   Hypertext Transfer Protocol
    GET /;fjdngskdjfng;lskdjfnglskdjfglskdjfgksjdfgn HTTP/1.1\r\n
        [Expert Info (Chat/Sequence): GET /;fjdngskdjfng;lskdjfnglskdjfglskdjfgksjdfgn HTTP/1.1\r\n]
        Request Method: GET
        Request URI: /;fjdngskdjfng;lskdjfnglskdjfglskdjfgksjdfgn
        Request Version: HTTP/1.1
    Host: www.boredomsoft.org\r\n

Response with no error document specified in CPanel:
Code:
No.     Time        Source                Destination           Protocol Info
     22 5.905480    66.40.52.73           192.168.1.149         HTTP     HTTP/1.1 302 Found HTTP/1.1 302 Found  (text/html)
   Hypertext Transfer Protocol
    HTTP/1.1 302 Found\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 302 Found\r\n]
        Request Version: HTTP/1.1
        Response Code: 302
   Hypertext Transfer Protocol
    HTTP/1.1 302 Found\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 302 Found\r\n]
        Request Version: HTTP/1.1
        Response Code: 302
        HTTP chunked response
Line-based text data: text/html
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n
    <HTML><HEAD>\n
    <TITLE>302 Found</TITLE>\n
    </HEAD><BODY>\n
    <H1>Found</H1>\n
    The document has moved <A HREF="https://cp.freehostia.com/404/">here</A>.<P>\n
    <P>Additionally, a 302 Found\n
    error was encountered while trying to use an ErrorDocument to handle the request.\n
    <HR>\n
    <ADDRESS>Apache/1.3.33 Server at boredomsoft.org Port 80</ADDRESS>\n
    </BODY></HTML>\n

Response with /errors/404.php specified in CPanel:
Code:
No.     Time        Source                Destination           Protocol Info
    187 1.444362    66.40.52.73           192.168.1.149         HTTP     HTTP/1.1 302 Found HTTP/1.1 302 Found  (text/html)
   Hypertext Transfer Protocol
    HTTP/1.1 302 Found\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 302 Found\r\n]
        Request Version: HTTP/1.1
        Response Code: 302
        Location: /errors/404.php\r\n
    Hypertext Transfer Protocol
    HTTP/1.1 302 Found\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 302 Found\r\n]
        Request Version: HTTP/1.1
        Response Code: 302
        HTTP chunked response
Line-based text data: text/html
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n
    <HTML><HEAD>\n
    <TITLE>302 Found</TITLE>\n
    </HEAD><BODY>\n
    <H1>Found</H1>\n
    The document has moved <A HREF="/errors/404.php">here</A>.<P>\n
    <P>Additionally, a 302 Found\n
    error was encountered while trying to use an ErrorDocument to handle the request.\n
    <HR>\n
    <ADDRESS>Apache/1.3.33 Server at boredomsoft.org Port 80</ADDRESS>\n
    </BODY></HTML>\n
Followed by:
Code:
No.     Time        Source                Destination           Protocol Info
    196 1.487887    192.168.1.149         66.40.52.73           HTTP     GET /errors/404.php HTTP/1.1
   Hypertext Transfer Protocol
    GET /errors/404.php HTTP/1.1\r\n
        [Expert Info (Chat/Sequence): GET /errors/404.php HTTP/1.1\r\n]
        Request Method: GET
        Request URI: /errors/404.php
        Request Version: HTTP/1.1

And then:
Code:
No.     Time        Source                Destination           Protocol Info
    295 2.011939    66.40.52.73           192.168.1.149         HTTP     HTTP/1.1 404 Not Found  (text/html)
Hypertext Transfer Protocol
    HTTP/1.1 404 Not Found\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 404 Not Found\r\n]
        Request Version: HTTP/1.1
        Response Code: 404
    Line-based text data: text/html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n
    <html xmlns="http://www.w3.org/1999/xhtml">\n
    <head>\n
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\n
    <title>404</title>\n
    <link rel="stylesheet" href="errors.css" type="text/css" />\n
    </head>\n
    <body bgcolor="#64748B">\n
    </head>\n
    \n
    <body>\n
    <p>&nbsp;</p>\n
    <p>&nbsp;</p>\n
    <p>&nbsp;</p>\n
    <p>&nbsp;</p>\n
    <table width="918" border="0" align="center">\n
      <tr>\n
        <td width="156" rowspan="4" class="bodyText"><img src="exclaimation.gif" width="151" height="151" /></td>\n
        <td class="bodyText"><span class="style5">HTTP Error 404: Inept or ham-handed user </span></td>\n
      </tr>\n
      <tr>\n
        <td width="903" bgcolor="#FFFFFF" class="bodyText"><ol>\n
            <strong>Emptiness</strong>:\n
    [truncated]         <li>The state of being empty; absence of contents; void space; vacuum; as, the emptiness of a vessel; emptiness of the stomach.</li><li>Want of solidity or substance; unsatisfactoriness; inability to satisfy desire; vac
            <li><strong>Want of knowledge; lack of sense; vacuity of mind</strong>.</li>\n
        </ol></p>    </td>\n
      </tr>\n
      <tr>\n
        <td bgcolor="#FFFFFF" class="style5"><div align="center">the page you asked for does not exist in our space-time continuum </div></td>\n
      </tr>\n
      <tr>\n
        <td bgcolor="#999999"><p><a href="javascript:history.go(-1)">Go back</a>, thee, from whence thou came. And darken not this URL again. For if thou dost not heed my words, then thou dost have the brain of birds. Amen </p>    </td>\n
      </tr>\n
    </table>\n
    <p align="center"><a href="http://www.boredomsoft.org">Go To Main Page </a></p>\n
    </body>\n
    </html>\n



Conclusions: .htaccess is being ignored. The server looks only to the CPanel setting for an error document. This error document is served along with a 302 header rather than a 404 header. If the error document specified in CPanel contains the PHP code to send a 404 response, this response is sent only AFTER the 302 response is sent, and is therefore useless.

HELP!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2011 5:35 pm 
Newbie
Newbie

Joined: Sun Feb 13, 2011 2:29 pm
Posts: 16
This problem still stays:
.htaccess is being ignored. The server looks only to the CPanel setting for an error document. This error document is served along with a 302 header rather than a 404 header.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2011 1:41 am 
Newbie
Newbie

Joined: Mon Aug 01, 2011 1:35 am
Posts: 1
Same problem here : my .htaccess seems to be ignored and the server looks to the cpanel for the et Error 404 page setting...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011