Call now! (ID:278675)+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/"); ? >

Unlimited Starter
Unlimited storage
Unlimited bandwidth
1 website hosted
30-Day Free Trial
$3.30 / month
Unlimited Gold
Unlimited storage
Unlimited bandwidth
5 websites hosted
30-Day Free Trial
$4.50 / 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"); ?>

Follow Us

twitter