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 🙂

 

setup web server centos with apache

Install Apache, Mysql , PhP Web Server

# yum install httpd mod_ssl

#/etc/init.d/httpd start

# yum install mysql mysql-server

# chkconfig –levels 235 mysqld on
# /etc/init.d/mysqld start

configure mysql

Set the MySQL service to start on boot
chkconfig –levels 235 mysqld on
Start the MySQL service
service mysqld start
Log into MySQL
mysql -u root
Set the root user password for all local domains
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘new-password‘);
SET PASSWORD FOR ‘root’@’localhost.localdomain’ = PASSWORD(‘new-password‘);
SET PASSWORD FOR ‘root’@’127.0.0.1′ = PASSWORD(‘new-password‘);
Drop the Any user
DROP USER ”@’localhost’;
DROP USER ”@’localhost.localdomain’;
Exit MySQL
exit

 

WP Twitter Auto Publish Powered By : XYZScripts.com