Deny IP Range in .htaccess file

Most of the time you need to block the whole range of IPs using .htaccess file and i recently noticed below code not working.

<Files ajay.php>
order deny,allow
deny from all
allow from 192.168.0.0/24
</Files>

After couple of searches i found the /24 doesn’t work here and you need to make the subnet mask as 255.255.255.0

 

to allow single IP is easy as below

<Files register.php>
order allow,deny
allow from 192.168.19.24
deny from all
</Files>

<Files search.php>
order deny,allow
deny from all
allow from 192.168.0.0/255.255.0.0
</Files>

 

in Linux life small changes make a big difference 🙂

 

It's only fair to share...Tweet about this on TwitterShare on Google+Share on FacebookShare on LinkedInEmail this to someone
Twitter Auto Publish Powered By : XYZScripts.com