【问题标题】:Ban IP by country via .htaccess but allow certain IPs from that country通过 .htaccess 按国家/地区禁止 IP,但允许来自该国家/地区的某些 IP
【发布时间】:2012-02-18 08:14:32
【问题描述】:

.htaccess 文件,请多多包涵。我想知道是否有任何方法可以禁止来自特定国家/地区的所有 IP,但只允许来自被禁止国家/地区的一两个 IP 访问该站点。这可能吗 ?提前致谢。

【问题讨论】:

    标签: .htaccess country


    【解决方案1】:

    http://www.countryipblocks.net/country-blocks/htaccess-deny-format/

    要允许某些 ips 使用类似的东西

    Order deny, allow
    Allow from 1.2.3.4
    

    编辑以明确放置它们的位置。

    我没有看到 <limit> 的用法,所以我删除了它。

    Order deny, allow
    #ips from the blocked countries that are are allowed
    Allow from YYY.YYY.YYY.YYY
    
    
    # 'deny'-code from website 
    # only copy the lines starting with 'deny'
    deny from XXX.XXX.XX.X/XX 
    deny from XXX.XXX.XX.X/XX 
    deny from XXX.XXX.XX.X/XX 
    # lines starting with a hash are comments so can be removed
    
    # all other ips are allowed
    

    【讨论】:

    • <limit get post> order allow,deny # Country: XXXXXX # ISO Code: XX # Total Networks: XXX # Total Subnets: XXXXX deny from XXX.XXX.XX.X/XX deny from XXX.XXX.XX.X/XX deny from XXX.XXX.XX.X/XX #allow from all </limit> 以上是我从网站收到的代码示例。我想知道在哪里添加您给我的代码? “1.2.3.4”也代表我想允许的IP吗?谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-04
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    相关资源
    最近更新 更多