htaccess access to file by ip range

前端 未结 7 2146
南笙
南笙 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: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.

提交回复
热议问题