htaccess redirect and http response codes

K

Karl Core

OK, related to yesterday's conversation, during which it was mentioned that
php's header(location: ) automatically sends the HTTP 301 response code, it
got me thinking - does this also happen automatically with a redirect from
..htaccess?

TIA
 
J

Jukka K. Korpela

GreyWyvern said:

Nope. As the cited document says,
"If no status argument is given, the redirect will be "temporary" (HTTP
status 302)." Thus, a simple

redirect /~jkorpela/foo http://www.cs.tut.fi/~jkorpela/bar

will send the 302 response code (which means that clients should keep
using the original address, instead of updating their hotlists,
databases, or whatever).

But you can make the server send a permanent redirect, i.e. response
code 301, in several ways:

redirect 301 /~jkorpela/foo http://www.cs.tut.fi/~jkorpela/bar
redirect permanent /~jkorpela/foo http://www.cs.tut.fi/~jkorpela/bar
RedirectPermanent /~jkorpela/foo http://www.cs.tut.fi/~jkorpela/bar

I have no idea why Apache chose the default of sending a temporary
redirect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top