Redirect based on referrer or IP address

posted on May 17, 2006, 5:06 pm
Comments
Jason DAngelo posted on February 10, 2007, 10:01 am
do not forget... some websites translate you hosts IP as the referrer... thus the /123.123.123.123/ as the referrer

Jason DAngelo posted on February 10, 2007, 9:59 am
I would try adding the other website referrers...
http://mydomain.com
http://www.mydomain.com
http://mydomain.com/
http://www.mydomain.com/

There are many formats... See if your referrer is getting od code... show your referrer as part of your page, to debug.

print ($referrer)

on your redirected page... or as your page...

Til posted on December 8, 2006, 11:31 am
Hi!
First, thanks a lot for this code! Now I have tried this code in my index.php on my homepage (in a subdirectory) and it works well with Firefox or Opera, but not with Internet Explorer! Using the
Internet Explorer the user is always redirected, even when he comes (is referred) from mydomain.com. Any idea how to correct this? Thanks in advance!
Mrs.Bungle.

here's my index.php:

<?
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/mydomain.com/",$referrer)) {
include("iindex.htm");
} else {
header('Location: http://mydomain.com');
};
?>

-----------------
PHPjabbers:
try using apache_request_headers() instead (formerly getallheaders).
<?php
$host=apache_request_headers();
if(!eregi('domain.com',$host[Referer])){
// TRUE
}else{
// FALSE
}
?>

bhaskar verma posted on August 18, 2006, 2:33 am
hello, ur logic of referer has helped me a lot.
Thnx ..

Pages:   1   2   
   
If you have any additions, suggestions or modifications for this example please contact us or use the form below.
   
Your name:
Your email: (email address will not be posted on the web site)
Comment:
Verification