Redirect based on referrer or IP address

posted on May 17, 2006, 5:06 pm
Comments
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