IP限制与htaccess的 [英] IP restriction with htaccess
问题描述
我想在这短短两年IP地址可以进入该网站的方式限制整个网站。我已经在我的.htaccess中的以下(在网站根目录):
I want to restrict an entire site in such a way that just two IPs could enter the site. I have the following in my .htaccess (at the root of site):
ErrorDocument 403 http://www.example.com/views/error403.html
Order Deny,Allow
Deny from all
Allow from 311.311.311 322.322.322.322
ErrorDocument 404 /views/error404.html
ErrorDocument 500 views/error500.html
(显然,这些都是假的IP地址,在我的.htaccess他们是正确的IP地址)
(Obviously, these are fake IPs, in my .htaccess they are the right IPs)
正如你所看到的,我让刚刚322.322.322.322和311.311.311.0/24所有的IP地址,并拒绝对人们的休息。我要的是,当有人从另一台IP进入现场,他会查看error403.html页面。
As you can see, I allow just 322.322.322.322 and all IPs from 311.311.311.0/24, and deny for the rest of people. What I want is that when anybody enter the site from another IP, he'll view the error403.html page.
过滤器工作正常,但不是重定向。当我尝试从拒绝IP地址进入网站,我看到一个Apache消息:
The filter is working fine, but not the redirection. When I try to enter the site from a deny IP, I see an Apache message:
Found
The document has moved here
在哪里这里是一个链接到error403.html。
Where "here" is a link to error403.html.
我觉得我限制甚至error403.html页面。
I think I'm restricting even the error403.html page.
我怎样才能做到这一点限制,但允许错误页面的看法?我应该error403.html页面移动到另一个目录(例如,/视图/错误/),并把其他的.htaccess在里面,允许在该文件中的所有IP地址?
How can I do this restriction, but allowing the view of the error page? Should I move error403.html page to another directory (i.e., /views/error/ ) and put other .htaccess in it, allowing in that file all the IPs?
感谢你在前进!
推荐答案
是的,你已经回答了你自己的问题。 :)将所有非保护的网页到另一个目录中有自己的的.htaccess
包含正确允许
和拒绝
。
Yes, you have answered your own question. :) Move all non-protected pages into another directory with its own .htaccess
containing the proper Allow
and Deny
.
这篇关于IP限制与htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!