DelphiFAQ Home Search:
General :: Linux :: Apache
Know-how about Apache, the most popular web server. Both Linux and Windows related information,

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

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

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>

Generated 20:00:42 on Sep 19, 2017