Is it possible to block a refferer using PHP? Don't tell me to do it by .htaccess .. I wanna know if it's possible via PHP.
Suppose I want to show a text to visitor that came from unblocked refferer or came without referrer and don't wanna show it to visitor came for blocked refferer.If I use following code.. <?php $ref=@$HTTP_REFERER; $blank = ""; $blockedref = "http://www.badhost.com/"; if($ref != $blank && $ref != $blockedref) echo "Text to show to unblocked refferer"; else die(); ?> PHP: It will only blocked the specific URL I defined in $blockedref .. If a visitor come from http://www.badhost.com/dir/page.php .. It will not block that. How can I block the entire URL ..
$blockedref = "badhost.com"; $ref = @$_SERVER['HTTP_REFERER']; if( $ref && strpos( $ref, $blockedref ) !== false ) die(); PHP: =;-)