0

我必须允许一些子站点链接我的页面,但我不想让主站点这样做。

主站点是 www.mainsite.com,该站点不得链接我的页面,但必须允许子站点 www.mainsite.com/subsite 链接这些页面,就像网络上的所有其他站点一样。简单来说,我想阻止那些从我的网站上窃取我的内容的网站,而无需询问权限或滥用我的带宽的网站。我试图这样做,但代码不起作用,有人可以帮助我吗?

代码:

<?php
$ref=$_SERVER['HTTP_REFERER'];

if (strpos($ref,'http://randomsite/allowedsite1')===0 || strpos($ref,'http://randomsite/allowedsite2')===0){} //If the referer comes from an allowed site, it must show the HTML below
if (strpos($ref,'http://randomsite/')===0 || strpos($ref,'http://anotherblockedrandomsite/')===0){
header('location: http://mycoolsite/nohotlink.png'); //if the referer comes from an blocked site, it redirects to an troll png
exit();
}
?>

<html>
My Password
</html>
4

1 回答 1

0

使用=== trueor=== false代替0. 0可以解释为INT

另一方面,请联系其他网站并告诉他们删除您的内容。这是做到这一点的唯一方法,你几乎无能为力。

于 2013-11-13T19:09:40.283 回答