How do I redirect 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:

<?php header("Location:
http://www.redirect.to.url.com/"); ?>

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

<?php header("Location: anotherDirectory/anotherFile.php"); ?>

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

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

FastCGI for PHP

FastCGI for PHP FastCGI for PHP makes all your PHP applications run through mod_fcgid instead...

Protecting the php.ini file from being viewed

To prevent people to viewing your php.ini file via a browser a few lines need to be pasted into...

Configuring the PHP Environment With php.ini

The servers use a master php.ini file for all directories without a php.ini file in it. You will...

Upload_Max_Filesize

In a nutshell: Locate the php.ini file in the folder your upload script resides in. If none...

How do I enable PHP 5 for my PHP applications?

1. Login to your Control Panel and click the PHP Config icon. 2. Select PHP5 (Single php.ini)....