Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: referer array
10-06-2012, 07:13 PM #1
Question, im trying to grab just the root of HTTP_REFERER.
The below will work but sometimes RERERER is like this
$ref = $_SERVER['HTTP_REFERER'];
$ok_array = array('http://www.mysite.com', 'www.mysitel.com', 'mysite.com');
if (array_key_exists($ref, $ok))
i guess i could use SERVER_NAME right
Last edited by durangod; 10-06-2012 at 11:33 PM.
10-06-2012, 08:23 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
No, server name will be your server.
You want to use parse_url():
so with your example, that would create $domain with the value of "www.mysite.com"PHP Code:
$domain = parse_url($ref, PHP_URL_DOMAIN);
// its in the array
Users who have thanked Fou-Lu for this post: