Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts

    404 Not Found to 200 OK

    I'm working on a certain template that is an error page fetching from the database based on the URI given.
    The thing is, if the error page finds the page in the DB, it uses header("HTTP/1.0 200 OK"), but that was still setting my pages as a 404 error status. Then I used header("Status: HTTP/1.0 200 OK") and now it's sending a 500 error status. Is there something I have to set in my php.in or httpd.conf? Or any other remedy? I'm using hostmonster as a host currently, and my site is http://www.blahertech.org/.

    If you go to /projects or something, you'll see it's coming up as a 500 error. The main page, /, doesn't because that file does exist.

    -Thanks in Advanced.
    Last edited by Blaher; 03-13-2008 at 01:29 PM.

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't understand the question at all. Could you clarify?

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts
    There is no more simple way of clarifying, all I want is a way to make my 404 error pages 200 OK. I used header("HTTP/1.0 200 OK"), but that did nothing. Now I'm using using header("Status: HTTP/1.0 200 OK"), but that makes it a 500 internal server error.

  • #4
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    Puerly out of curiosity, why do you want your error page to return a 200 response?

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts
    User: Here's my post data and stuff, give me /projects please.
    Server: /projects not found, but .htaccess says the 404 error document is /index.php.
    Server: reading php... searching MySQL for the URI of "/projects".
    Server: "/projects" found in MySQL.
    Server: The Error status is now 200 OK, this page does exits.
    Server: !!!!500 INTERNAL SERVER ERROR!!!!
    Server: Sending content to user
    User: thanks, I got the /projects page as a 500 Status
    IE-Users: the /ad page is also 500, so I'm lazy and not going to display it through the object.

  • #6
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    header'HTTP/1.1 200 OK' ); 

  • #7
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Blaher View Post
    The thing is, if the error page finds the page in the DB, it uses header("HTTP/1.0 200 OK"), but that was still setting my pages as a 404 error status.
    Quote Originally Posted by kbluhm View Post
    PHP Code:
    header'HTTP/1.1 200 OK' ); 
    EDIT: Oh I see now, I used 1.0 instead of 1.1. Thanks

    edit: ok, in my code I am using 1.1, I made a mistake when I typed it. I also heard somewhere to use header("Status: HTTP/1.1 200 OK"); but that's the one giving me a 500. The other on isn't changing at all.
    Last edited by Blaher; 03-14-2008 at 03:28 AM.

  • #8
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Ok, I used header("HTTP/1.1 300 OK") and firebug isn't showing any problems anymore. Although, I'm not sure about IE, but I'm wondering if this is a good idea?

    EDIT: Ok, this doesn't fix my problem with googlebot reporting errors.

    EDIT: Ok, I used 201 Created, and it works fine now. 201 fits my pages better anyways, because I'm making the page as it loads I guess.

    EDIT: google doesn't like 404 pages going 2xx...
    Last edited by Blaher; 03-14-2008 at 03:29 AM.


  •  

    Posting Permissions

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