views:

48

answers:

3

I have a web application where the requested URL is used in a REST-like fashion. However, if no URL is entered (just the domain) I re-direct to http://www.example.com/home and then my home controller is loaded.

What HTTP status code should I use for this re-direct? This process takes place in my index.php script using a simple header('Location: home') call.

Clarification: this may not be permanent, but will remain present in this version of the application. So for example, if this application were to be redeveloped in the future then the new developer may chose to once again serve requests from the root. I would imagine this then narrows my choices to:

  • 303 See Other
  • 307 Moved Temporarily
+1  A: 

I'd favor 302 "Found" for this use; that tells the user-agent that they can/should continue requesting / in the future because someday the redirect might be different. (But I could make a case for 301 "Moved Permanently", too.)

pjmorse
Yeah. My reasoning was I didn't want to break it if in the future requests were able to be served from the root of the domain again.
Martin Bean
If you don't send a Cache-Control or Expire header as well then issuing 302 is meaningless.
racetrack
+2  A: 

based on http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 1 would say 301, Moved Permanently

dschadlich
+1 for providing the link.
pjmorse
A: 

Code 301. After some time 410 (If you want requesters not to reference deprecated URL in their code).

Toto