The blog of Jafar Aliyev

Archive

Creation date:

Hot linking prevention in .htaccess

Hot linking is direct linking to a web site's files (images, video, documents and other resources). An example would be using an <img> tag to display a JPEG image you found on someone else's web page so it will appear on your own site. Hot linking is very common. Since the images are hosted remotely away from the website someone else can use your website bandwidth and resources. Theft of images may not be so terrifying as other resources. I give you here the solution of problem on site level.

This rewrite rule is being used to prevent hot linking.

RewriteEngine onRewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://portfolio.domain.com/.*$ [NC]
RewriteRule .*.(gif|GIF|jpg|JPG|png|PNG|doc|DOC|pdf|PDF|txt|TXT|pl|PL|ico|ICO|css|CSS|js|JS)$ - [F]

Author: Jafar N.Aliyev (Jsoft)

Read also

HTML tips
Here I listed some useful HTML tips

Use site WITH WWW or WITHOUT WWW prefix

Download instruction in .htaccess

redirect 301

© Copyright

All articles in this site are written by Jafar N.Aliyev. Reproducing of any article must be followed by the author name and link to the site of origin(this site). This site also keeps the same rules relative to the articles of other authors.