Page redirect with 200 Ok status does not work!

Discussion in 'PHP' started by ahelpinghand, Apr 9, 2008.

  1. #1
    When I try to redirect to a web page using php like this:

    header("HTTP/1.1 200 Ok");
    header("Location: /some/internal/url");

    php does not send "200 Ok" status, instead it sends the default 302 status! any other status like 301, 302 work normally, I wonder why this is happening?

    The case is, I have link structure like this: HomePage->Page A->Page B, I want PageRank to pass normally when linking from Page A to Page B and I don't want to use direct normal link because I want to count views to Page B and I don't want to include a counting script in Page B because I have so many.

    How can I redirect using status 200 with php header function?
     
    If someone posts a solution, use the "Best Answer" link in their post to pick it as the best answer.
    ahelpinghand, Apr 9, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't truly know this but I would *think* it shouldn't be possible at all. You shouldn't be allowed to fool browsers and such into thinking that the page loaded okay but also have it redirect to another page. If you redirect by changing the header location, it's going to let it know it redirected which is a 301 or 302. I'd assume being able to still set it as a 200 and redirect would be a bad internet flaw.. would make it easier to hijack pages for page rank and stuff.
     
    zerxer, Apr 9, 2008 Set Best Answer IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    Best you can do is trick the server into sending both a 200 and a redirect. But the browser/search-engine is going to completely ignore the 200 as soon as it comes across the new HTTP "Location" header. As it should.
     
    joebert, Apr 10, 2008 Set Best Answer IP