Knowledgebase

How do I redirect visitors to another page using PHP?

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:

header("Location: http://www.redirect.com/");
exit;

Where 'http://www.redirect.com/' is the URL you wish the users to be redirected too. This can also be a file, like so:

Files can be of anytime including but not limited to HTML, python, php, cgi, perl , and compiled cgi programs.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read