从除一人外所有域拒绝转介 [英] Deny referrals from all domains except one
问题描述
是否有可能接受只有一个域的流量,最好使用.htaccess文件? 我希望我的网站只能通过在其他网站上我有一个链接访问。
Is it possible to accept traffic from only one domain, ideally using a .htaccess file? I want my site to only be accessible via a link on another site I have.
我知道如何阻止1指域,但不是所有的域
I know how to block one referring domain, but not all domains
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} otherdomain\.com [NC]
RewriteRule .* - [F]
这是我的全部重写code:
this is my full rewrite code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !domain\.co.uk [NC]
RewriteRule .? - [F]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
我觉得这是工作,但没有任何资产被越来越加载,我得到一个500错误,当我点击另一个链接。
I think it is working, but none of the assets are getting loaded and I get a 500 error when I click on another link.
推荐答案
请说是这样的:
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !yourdomain\.com [NC]
RewriteCond %{HTTP_REFERER} !alloweddomain\.com [NC]
RewriteRule .? - [F]
第一个的RewriteCond
检查该引用不为空。第二个检查,它不包含字符串 yourdomain.com
,第三,它不包含字符串 alloweddomain.com
。如果所有这些检查通过,则重写规则
触发器和拒绝请求。
The first RewriteCond
checks that the referrer is not empty. The second checks that it doesn't contain the string yourdomain.com
, and the third that it doesn't contain the string alloweddomain.com
. If all of these checks pass, the RewriteRule
triggers and denies the request.
(允许空的引荐通常是一个好主意,因为浏览器可以生成它们由于种种原因,如当:
(Allowing empty referrers is generally a good idea, since browsers can generate them for various reasons, such as when:
- 用户书签链接,
- 用户手动输入链接到地址栏,
- 在用户重新加载页面,
- 在浏览器配置不发送跨站点引用infromation,或
- 您的网站和浏览器之间的代理除掉引荐信息。)
这篇关于从除一人外所有域拒绝转介的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!