Forum Moderators: coopster
Well I was trying to redirect traffic from a certain referer and was going to use this:
<?
if ($HTTP_REFERER= 'www.somedomain.com')
{
header ("Location: somepage.html");
}
?>
Just needed to know how do I get the traffic that is not form the referer to go to another page. Can I just repeat the above coding but leave the variable blank?
In other words is this correct?
<?
if ($HTTP_REFERER= 'www.somedomain.com')
{
header ("Location: somepage.html");
}
if ($HTTP_REFERER= '')
{
header ("Location: somepage.html");
}
?>
or this?
<?
if ($HTTP_REFERER= 'www.somedomain.com')
{
header ("Location: somepage.html");
}
?>
<?
if ($HTTP_REFERER= '')
{
header ("Location: somepage.html");
}
?>
If someone can get me going in the right direction or if I need another "if" statement please let me know.
You can use the else [php.net] part of the if [php.net] control structure.
By the way, a word of caution when relying on REFERER -- web browsers may not send the referer along and it cannot be trusted. A quick search over the forums will turn up plenty of reading.
Also, when using a redirect header as you are, you should really be using the full url and not just a relative path. More information on the PHP manual page for header [php.net].