Topic awaiting preservation: PHP: Domain-based redirection via an array... |
|
---|---|
Author | Thread |
Bipolar (III) Inmate From: USA |
posted 08-18-2005 23:22
I'm trying to create a page that will redirect users from a few different sites to a different page, and I'm having some trouble making it work for more than one page. Basically, here's what works for one page: code: <?php $comingFrom = $_SERVER['HTTP_REFERER']; $itWorked = "It worked, indeed!"; $sitesArray = array("mydomain.com", "otherdomain1com", "otherdomain2.com"); ?>
code: <?php if(substr_count($comingFrom, 'mydomain.com')) { echo $itWorked; } else { echo $comingFrom; } ?>
|
Bipolar (III) Inmate From: f(x) |
posted 08-19-2005 02:28
code: <?php $from = parse_url($comingFrom); $pattern = '#('.str_replace('.','\.',implode('|',$sitesArray)).')$#i'; if(preg_match($pattern,$from[host])) { echo $itWorked; } else { echo $comingFrom; } ?>
|
Bipolar (III) Inmate From: USA |
posted 08-19-2005 03:37
Thank you very much. Excellent work. |