Call now! (ID:304399)+1-855-211-0932
HomeHosting ArticlesHow to code a PHP redirect – Header Redirect with PHP

PHP Header redirect

Redirecting traffic with PHP requires the use of the header() function. Add the lines of code to a newly created PHP file e.g. index.php. This index file can be placed in your root folder or any of your choice.

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

Basic
Unlimited storage
Unlimited bandwidth
1 website hosted
30-Day Free Trial
$7.50 / month
Advanced
Unlimited storage
Unlimited bandwidth
5 websites hosted
30-Day Free Trial
$10.00 / month
 


If you are redirecting to a file the following can also be utilized.
<?php header("Location: newDirectory/PHPFile.php"); ? >

OR if it is to a HTML file
<?php header("Location: newDirectory/HTMLFile.html"); ?>