faqts : Computers : Programming : Languages : PHP : Function Libraries : HTTP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 5 people (40%) answered Yes
Recently 2 of 5 people (40%) answered Yes

Entry

How can I redirect the browser to a different site (I don't need to pass variables)?

Nov 13th, 2005 03:44
Matthew Wilkinson, Robert Boyer,


There are several ways.
The easiest is to just send header('Location:
http://www.you.com/hello'); where you.com/hello is the webpage you want
ot redirect to. You must include the http:// or https:// or ftp:// etc.
This way works, but it is not very user friendly, especially to screen
readers etc.
To send it properly, you should send a HTTP code such as Temporary
Redirect or Permanent Redirect. You would do this using the coe below:
header('HTTP/1.1 301 Moved Permanently');
--OR--
header('HTTP/1.1 307 Temporary Redirect');
--THEN--
header('Location: http://www.you.com/hello');