如果某人是从特定域引用的,如何显示特殊代码
有人欺骗了我的网站(使用 .org 并放入流产胎儿的图片),而我无法将其删除。 但是这个白痴将所有链接保留在首页上,因此只要有人点击链接,他们就会从该网站转到我的网站。
我想向从该欺骗域引用的人显示一些代码,上面写着“注意:您来自我们网站的欺骗版本”。
最好的方法是什么? Google Analytics 已经能够检测到该 .org 的引用站点,但我不知道如何实现代码...
我的站点使用的是 WordPress 2.8,而且我对 PHP 相当了解。
Someone has spoofed my site (taking the .org and putting in pitures of aborted fetuses), and I'm unable to get it down. But the idiot kept all the links on the front page, so as soon as someone clicks a link, they're taken from that site to mine.
I want to display some code that says "NOTICE: YOU HAVE COME FROM A SPOOFED VERSION OF OUR SITE" to people who are referred from that spoofed domain.
What's the best way to do that? Google Analytics has been able to detect the referring site as that .org, but I don't know how to implement the code...
My site is on WordPress 2.8, and I'm fairly PHP knowledgable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要在您正在服务的页面中添加这些行
you need to add these lines in the page you are serving
引用者信息可通过
$_SERVER
获取 超全局。一个简单的测试看看是否提到了域名您只需要一个
if
语句即可。The referer information is available though the
$_SERVER
superglobal.A simple test to see if the domain is mentioned wrapped in an
if
statement should be all you need.此代码检查是否设置了引荐来源网址(如果访问者直接访问您的网站,则可能不会设置),然后检查引荐来源网址的开头是否与欺骗网站的 URL 匹配(允许欺骗网站)使用 http 或 https 以及使用或不使用 www。)。 仅检查引荐来源网址的开头意味着他们可以向其网站添加其他页面,但仍会检查欺骗行为。
This code checks to see if the referer is set (if the visitor is coming directly to your site, it may not be set) and then it checks if the start of the referer matches the URL of the spoof site (allowing for the spoof site to use http or https and to use or not use www.). Checking just the start of the referer means that they can add additional pages to their site, but it will still check for spoofing.
您可以查看 HTTP_REFERER 变量的内部 http://en.wikipedia.org/wiki/HTTP_referrer< /a>
请注意,某些反恶意软件会隐藏此变量以避免用户跟踪。
You can take a look inside the HTTP_REFERER variable, http://en.wikipedia.org/wiki/HTTP_referrer
Be warned, some antimalware software hides this variable to avoid user tracking.