Denying Access

Other topics

Denying IPs

order allow,deny
deny from 255.0.0.0
allow from all

This denies access to the IP 255.0.0.0.

order allow,deny
deny from 123.45.6.
allow from all

This denies access to all IPs in the range 123.45.6.0 to 123.45.6.255.

Hot Link Prevention

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|css)$ - [F]

This blocks all the links to '.gif', '.jpg' and '.css' files which are not from the domain name http://www.yourdomain.com.

Display alternate content:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/angryman.jpg [R,L]

This blocks all links to '.gif' and '.jpg' files which are not from the domain name 'http://www.yourdomain.com/' and displays the file 'http://www.yourdomain.com/angryman.jpg' instead.

Denying access from IPs to files/directories

# Deny access to a directory from the IP 255.0.0.0
<Directory /path/to/directory>
    order allow,deny
    deny from 255.0.0.0
    allow from all
</Directory>

# Deny access to a file from the IP 255.0.0.0
<FilesMatch "^\.ht">
    order allow,deny
    deny from 255.0.0.0
    allow from all
</FilesMatch>

Contributors

Topic Id: 4741

Example Ids: 7148,10781,16677

This site is not affiliated with any of the contributors.