wordpress - Redirect people who visit from a specific link to another page -
i have situation a.com link products, , have visitors come check out, , discussing it.
i not want this, nore interested in pointless visits, eats away @ bandwidth.
i want manually place code in product page's header, or .htaccess file, redirect a.com, a.com, or google.com
a typical link come in format:
forum.a.com/showthread.php?t=1111111
i know can code:
rewriteengine on # options +followsymlinks rewritecond %{http_referer} badsite\.com [nc] rewriterule .* - [f]
but not wish show "forbidden" message. want kindly show them on way away site.
solution:
<?php $http_referrer=$_server['http_referer']; if ($http_referrer) { // check if referrer on noentry list // if redirect page if ($http_referrer == "http://website.com") { header("location: http://gotothiswebsiteinstead.com"); die(); } } else { //everything ok } ?>
something should want:
$refererhost = parse_url($_server['http_referer'], parse_url_host); if (preg_match('/^(www\.)?badhost\.com$/i', $refererhost)) { header('location: ' . $_server['http_referer']); die(); }
however, aware fake referer.
Comments
Post a Comment