If you need your PHP script to redirect to a different website, you can send an HTTP header to do that.

Remember, header() must be called before any actual output is sent, which includes not just HTML, but blank lines, etc.. as well.


// Tell the web browser that the page has been moved to a new location

if (strpos(PHP_SAPI, 'cgi') === 0)
	// If CGI interface between web server and PHP
	header('Status: 301 Moved Permanently', true);
	header('HTTP/1.1 301 Moved Permanently', true, 301);

// Execute the redirect
header("Location: https://www.example.com/foo.html");

// Don't process or spit out anything in the script after this
About the Author
Member Avatar Dani The Queen of DaniWeb

I'm a super-geeky programmer with a passion for Internet marketing. :)

That was a big help. Thank You so much!

Redirection in PHP can be done using the header() function. To setup a simple redirect, simply create an index.php file in the directory you wish to redirect from with the following content: < ?php header("Location: http://www.redirect.to.url.com/"); ?>