htaccess规则。仅允许来自特定IP和Referer

时间:2014-11-06 15:28:40

标签: .htaccess

我正在尝试添加将执行以下操作的htaccess规则。

允许指定IP(

允许来自特定推荐(另一个域)

拒绝所有其他人

拒绝重定向到特定网址。 (另一个域名)

这是一个wordpress网站,并考虑使用htaccess,除非有另一种方式。谢谢你的帮助提前。

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.your_domain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.another_domain\.com/ [NC]
RewriteRule ^.*$ http://www.another_domain.com/not_allowed_here.htm [R=301,L]

ErrorDocument 403 http://www.another_domain.com/specific_page.html
order deny,allow
deny from all
allow from 111.222.333.444

用户参与同一测试:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.your_domain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.another_domain\.com/ [NC]
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444$
RewriteRule ^.*$ http://www.another_domain.com/not_allowed_here.htm [R=301,L]
相关问题