的.htaccess阻止所有,但我的IP [英] .htaccess block all but my ip
问题描述
我试图做一个快速的htaccess来阻止所有,但我的IP。
I'm trying to do a quick htaccess to block all but my ip.
我有这样的
order deny, allow
deny from all
allow from "MY IP"
我的IP我的IP地址
"MY IP" is my ip
我看不到,如果从我的IP? - 这是做到这一点的正确方法
I can't see if from my ip - is this the correct way to do this ?
推荐答案
最有效的方法是使用专为任务的指令自己白名单。
The most efficient way is to white list yourself using the directive designed for that task.
Order Allow,Deny
Allow from 123.456.789.123
其中123.456.789.123是静态IP地址。
Where 123.456.789.123 is your static IP address.
在使用订单允许,拒绝指令的要求必须匹配允许或拒绝,如果没有得到满足,该请求被拒绝。
When using the "Order Allow,Deny" directive the requests must match either Allow or Deny, if neither is met, the request is denied.
<一个href="http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order">http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
或者你可以用mod_rewrite的做到这一点,像这样。
Or you could do it with mod_rewrite like so.
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.123$
RewriteRule .* - [F]
请注意,RewriteEngine叙述上将是多余的,如果你已经摆在你的规则上面这一个。所以,如果是这样的话,你可以在这里将其丢弃。
Note that 'RewriteEngine On' will be redundant if you already have placed in your rules above this one. So if that's the case you can discard it here.
这篇关于的.htaccess阻止所有,但我的IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!