Skip to content
Advertisement

htaccess access to file by ip range

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 configure access to only ONE file not to directory.

Advertisement

Answer

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” :

JavaScript

The following would ONLY block admin.php :

JavaScript

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

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement