htaccess access to file by ip range

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

提交回复
热议问题