htaccess access to file by ip range

前端 未结 7 2069
南笙
南笙 2020-12-05 02:03

How to allow access to file only to users with ip which are in a range of ip addresses?

For example file admin.php. and range from 0.0.0.0 to 1.2.3.4.

I need

相关标签:
7条回答
  • 2020-12-05 02:45
    Order Deny,Allow
    Deny from all
    Allow from 311.311.311 322.322.322.322
    

    See answer here

    0 讨论(0)
  • 2020-12-05 02:48

    You cannot match an IP range with allow, but you can emulate it with a CIDR notation:

    Order allow,deny
    
    # 0.0.0.0 - 0.255.255.255.255
    Allow from 0.0.0.0/8
    
    # 1.0.0.0 - 1.1.255.255
    Allow from 1.0.0.0/15
    
    # 1.2.0.0 - 1.2.1.255
    Allow from 1.2.0.0/23
    
    # 1.2.2.0 - 1.2.2.255
    Allow from 1.2.2.0/24
    
    # 1.2.3.0 - 1.2.3.3
    Allow from 1.2.3.0/30
    
    # 1.2.3.4
    Allow from 1.2.3.4
    
    0 讨论(0)
  • 2020-12-05 02:49

    check the man page of the Allow Directive

    Order Deny,Allow
    Deny from all
    Allow from 10.1.0.0/255.255.0.0
    

    A partial IP address

    Example:

    Allow from 10.1
    Allow from 10 172.20 192.168.2
    

    The first 1 to 3 bytes of an IP address, for subnet restriction.

    A network/netmask pair

    Example:

    Allow from 10.1.0.0/255.255.0.0
    

    A network a.b.c.d, and a netmask w.x.y.z. For more fine-grained subnet restriction.

    A network/nnn CIDR specification

    Example:

    Allow from 10.1.0.0/16
    

    Similar to the previous case, except the netmask consists of nnn high-order 1 bits.

    0 讨论(0)
  • 2020-12-05 02:51

    if you to provide a wildcard 0.0.255.255

    Order allow,deny
    # 1.2.0.0 - 1.2.255.255
    Allow from 1.2.0.0/16
    

    This will give a range from 1.2.0.1 - 1.2.255.254

    you can also check here

    0 讨论(0)
  • 2020-12-05 02:57

    If you are using WordPress, then the Best and Simplest method is to install the plugin - LionScripts : WordPress IP Blocker from their website http://www.lionscripts.com/ip-address-blocker

    Their Professional version has much more features like country blocking and IP range blocking, bulk csv uploading etc.

    0 讨论(0)
  • 2020-12-05 03:00

    Just do this for a single IP:

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from 1.2.3.4
    </Limit>
    

    If you want to do it for a range like 10.x.x.x, then do this:

    <Limit GET POST> 
    order allow,deny 
    allow from 10
    deny from all
    </LIMIT>
    
    0 讨论(0)
提交回复
热议问题