proper http headers to send when switching blog from one domain to another
Just wondering what the ex开发者_Go百科act 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
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.
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.
精彩评论