Page 1 of 1

need help with HTTP_REFERER and redirection

Posted: Tue Nov 04, 2003 3:06 pm
by Syntax
OKay my problem is this.
i need for ppl who come from a domain to be redirected to a certain page

maybe this explenation is better


user comes to my page from DomainBAD he is supposed to be redirected to PAGE.BAD

user comes from any other site user gets the normal page.

Code: Select all

<?php
if ($HTTP_REFERER == "http://domain.BAD/*") 
&#123;  
header("location:http://domain.com/pageBAD.php"); 
&#125; //check for referer success 
else &#123; 

 &#125; //continiue..
?>
Thats what i have so far.
i need it to check the whole domain not just pages.
right now http://www.domain.BAD/page.html get the normal page
i can't keep adding pages that's too much job.

so how can i `redirect all from domain.BAD ??

Posted: Tue Nov 04, 2003 3:19 pm
by JAM
You might want to consider using something using;
http://se.php.net/manual/en/function.isset.php
http://se.php.net/manual/en/function.strstr.php

Code: Select all

<?php
if (isset($_SERVER['HTTP_REFERER'])) { // is it set at all?
    if (strstr($_SERVER['HTTP_REFERER'],'.disney.')) { // match finding
        // .disney. found in referer.
    } else {
        // .disney. not found in referer.
    }
} else {
 // referer is not set, act upon that...
}
?>
strstr is not 100% proof that it's actually the domain found, but closeby. http://www.disney.com/foo.php is in the above just as true as http://www.example.com/a.disney.page.html.

Posted: Tue Nov 04, 2003 3:49 pm
by Syntax
Thanks that worked!
Thanks a bunch!