Quick PHP Permanent Redirect

There are many different ways to redirect a visitor from one URL to another. I prefer the PHP redirect. Let’s say for example you are an affiliate for a new online store and they have given you a unique affiliate link to post on your blog to track the referrals you generate. Most of the time, this link it pretty ugly. You may want to have a URL that looks more professional or perhaps easier for someone to type or remember. You can redirect visitors from the pretty URL to the actual affiliate link instantly and still receive credit for the referral.

Like I said, there are many ways to do this, here is one…

Execute a PHP 301 Permanent Redirect

  1. Create an empty PHP file. e.g. redirect.php
  2. Copy the code below and paste it within the file.
  3. Make sure there are no spaces or other characers before the first
  4. Save. & upload.

[php]

<?
header("HTTP/1.1 301 Moved Permanently");
header("location: http://www.domain.com");
exit();
?>

[/php]

About Clifton Hatfield

Clifton is the kind of guy that can read code better than he can read a book and prefers it that way. He likes cold pizza, moving sidewalks, and Indiana Jones. Clifton co-founded Internet Lifestyle Network from his home office in 2012 and he believes that true leadership is to inspire.
0 comments