how does one send a "302 redirect" http header?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence k

    #1

    how does one send a "302 redirect" http header?

    Not especially a PHP question, but how does one indicate a 302
    redirect? Or does Apache do that automatically if I use PHP to send a
    location header?

    On Accumulist, if you click a title, you go first to Accumulist again,
    and then you are redirected to whatever article you might want to read:


    http://www.accumulist.com/


    Does Apache send a redirect code? Or do I have to?

  • John Dunlop

    #2
    Re: how does one send a "302 redirect" http header?

    lawrence k:
    [color=blue]
    > Not especially a PHP question, but how does one indicate a 302
    > redirect? Or does Apache do that automatically if I use PHP to send a
    > location header?[/color]

    header('Locatio n: ... ') causes Apache to send a 302 unless you have
    already sent another 3xx response (e.g., header('HTTP/1.1 301 ... ')).
    It's documented at



    --
    Jock

    Comment

    • Colin McKinnon

      #3
      Re: how does one send a "302 redirect" http header?

      lawrence k wrote:
      [color=blue]
      > Not especially a PHP question, but how does one indicate a 302
      > redirect? Or does Apache do that automatically if I use PHP to send a
      > location header?
      >[/color]

      No, when you use PHP to send a location header you are doing that, however
      the default behaviour in PHP is to do exactly what you suggest - i.e. send
      a 302 header - this is most likely WRONG, and really you should be sending
      a 301,303 or 307 depending on the context. RTFM.

      C.

      Comment

      Working...