Hypertext Access file

Denying Access

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} !^https://(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 https://www.yourdomain.com.

Display alternate content:

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

This blocks all links to ‘.gif’ and ‘.jpg’ files which are not from the domain name ’https://www.yourdomain.com/’ and displays the file ’https://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>

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow