htaccess access to file by ip range

前端 未结 7 2070
南笙
南笙 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 03:08

    Just add a FilesMatch or Files directive to limit it to a specific script.

    The following would block acces to all scripts ending in "admin.php" :

    <FilesMatch "admin\.php$">
        Order deny,allow
        Deny from all
        Allow from 10.0.0.0/24
    </FilesMatch>
    

    The following would ONLY block admin.php :

    <Files "admin.php">
        Order deny,allow
        Deny from all
        Allow from 10.0.0.0/24
    </Files>
    

    For more information refer to the apache docs on Configuration Sections.

    0 讨论(0)
提交回复
热议问题