PHP script to only allow traffic from certain domain

Website

Supreme Member
Joined
Feb 8, 2008
Messages
1,260
Reaction score
287
Is there a simple script to only allow traffic from a referring domain of my choice to a landing page of my choice and send all other visitors to another page of my choice?
 
There sure is, and it's very simple.

Paste the following code into the header of your site:

Code:
<?
$referrer = $_SERVER['HTTP_REFERER'];
    if (preg_match("/[COLOR=Red]domainnamehere[/COLOR]/",$referrer)) {
      header('Location: http://www.yourwebsite.com/special-page');

} else {
      header('Location: http://www.yourwebsite.com/regular-page');
};
?>
Where it says "domainnamehere", leave off the "http://", "www." & ".com" So if the URL is http://www.somesite.com, put it in there as somesite

I also suggest you give this post a read:
http://www.blackhatworld.com/blackhat-seo/2720057-post10.html
 
Last edited:
Back
Top