help with redirect script pertaining to referer

turbotec

BANNED
Joined
Apr 5, 2008
Messages
181
Reaction score
15
so I am using this script to redirect users if they have a blank referrer:

Code:
?php
	$referer = $_SERVER['HTTP_REFERER'];
	if($referer == "")
	{
		echo '<meta http-equiv="refresh" content="0;url=http://www.yahoo.com">';
	}
	else
	{
		echo '<meta http-equiv="refresh" content="0;url=http://www.google.com">';	
	}
?>


NOW here is my question. this code above sends users to www. yahoo.com IF the referrer is blank. how can I get it to redirect if and only if the Referrer is http://www.ABC123.com/index.htm

I tried putting in http://www.ABC123.com/index.htm inbetween the "" in the above code, but it only goes to the 'else' page even when the real referrer is http://www.ABC123.com/index.htm
 
Try this

PHP:
<?php
    $referer = $_SERVER['HTTP_REFERER'];
    if(strstr($referer,"ABC123.com/index.htm"))
    {
        echo '<meta http-equiv="refresh" content="0;url=http://www.yahoo.com">';
    }
    else
    {
        echo '<meta http-equiv="refresh" content="0;url=http://www.google.com">';    
    }
?>
 
Could this be used as a "key" to a page that you don't want the network to see?

Like let's say this redirects to a page you want to keep hidden - the only way to the "bad page" is by passing through this "key page" - if anybody tries to enter any other way, another page is presented and looks clean.

I know it can be done with different domains and such, but I'd rather a self contained script that can be kept in one folder.

Is this possible and who can code it?

Try this

PHP:
<?php
    $referer = $_SERVER['HTTP_REFERER'];
    if(strstr($referer,"ABC123.com/index.htm"))
    {
        echo '<meta http-equiv="refresh" content="0;url=http://www.yahoo.com">';
    }
    else
    {
        echo '<meta http-equiv="refresh" content="0;url=http://www.google.com">';    
    }
?>
 
Could this be used as a "key" to a page that you don't want the network to see?

Like let's say this redirects to a page you want to keep hidden - the only way to the "bad page" is by passing through this "key page" - if anybody tries to enter any other way, another page is presented and looks clean.

I know it can be done with different domains and such, but I'd rather a self contained script that can be kept in one folder.

Is this possible and who can code it?
Late Reply. Yes it is possible.
 
haha, nice bump bozo.

This can be done on the same domain, in several different ways. Probably the simplest and best way is to drop a cookie saying he visited the "key" page.

hehehe, I figured it would look so after the browser ate my more helpful comment when I tried to edit it, so I manually quoted him added "late reply" and 3 other words :). I'm actually doing the cookie drop and also a javascript redirect that would keep the referer. The cookie drop method is a little more subtle than the javascript redirect.
 
Back
Top