DelphiFAQ Home Search:

Blocking (part of) a web site for certain IP numbers

 

comments3 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

Question:

I want to block AOL users from seeing a certain part of my web site. How can I do this? My web server is Apache.

Answer:

Blocking AOL users means blocking certain IP numbers. You need to place all the to-be-blocked content in one folder (directory) - it may have sub directories.

Then in that folder, create a text file named .htaccess. Put the text shown in the box below in your .htaccess file.

In an htaccess file, you begin the line with a hash (#).

Alternatively, you can set up the same in your apache configuration file /usr/local/apache2/conf/httpd.conf. Add a section there that looks like example 3.

A note on the order deny, allow line. You have the choice between deny, allow and allow, deny:
  • order deny, allow
    The Deny directives are evaluated before the Allow directives. Access is allowed by default. Any client which does not match a Deny directive or does match an Allow directive will be allowed access to the server.
  • order allow, deny
    The Allow directives are evaluated before the Deny directives. Access is denied by default. Any client which does not match an Allow directive or does match a Deny directive will be denied access to the server.

#--- example 1 -----------------------------------------------
# text file .htaccess in protected directory
# blocking IP range 216.239.0.0 - 216.239.255.255 (Google.com)
order allow,deny
deny from 216.239.0.0/16

#--- example 2 -----------------------------------------------
# text file .htaccess in protected directory
# blockig AOL users
order allow,deny
deny from .aol.com

#--- example 3 -----------------------------------------------
# add this section to your httpd.conf file and restart apache
<Directory /www/no_aol/>
  order allow,Deny
  deny from .aol.com
</Directory>

Comments:

2006-04-15, 10:02:15
anonymous from United States  
rating
THis was very helpfull specially example # 3 ..

Jerry
2006-08-14, 07:04:28
anonymous from India  
order allow,deny
deny from 216.239.0.0/16

what is 216.239.0.0/16 ???
0/16 what does it means
2006-08-14, 07:13:27
anonymous from India  
order allow,deny
deny from 216.239.0.0/16

what is 216.239.0.0/16 ???
0/16 what does it means

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: