tags:

views:

16

answers:

2

Heya, Just wondering what the exact correct header is to send along when I redirect requests from one server (eg. abc.com) to another (eg. def.com/blog/).

I've got the redirects working right, but always get confused as to the exact header to send along with it.

Any help would be greatly appreciated. Thanks. Oliver

A: 

The header that indicates the new location is the Location header:

Location: http://def.com/blog/

If the change is permanent, you send a 301 response code (Permanent Redirect) so that clients may cache the forward.

Artefacto
+2  A: 

In PHP you would do it like this:

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://def.com/blog/');

You'd change "301 Moved Permanently" to "302 Found" if you are not sure it's permanent.

thomasrutter
Cool thanks. I'm actually doing via apache, so I'll just send a long a R=301 flag in the RewriteRule. Thanks duuuuude.
onassar