Depiction- Webmaster Resources
Stock Image

Contributors: Advertise Here  |  Advertise Here  |  Advertise Here

Misc Links: Submit Tutorials (Earn $$) l Advertising l Privacy Policy | Site Map

Tutorials > .htaccess > Hotlink Protection


Prevent other sites from linking to images on your site.

Bandwidth theft or "hotlinking" is direct linking to a website's files (images, video, etc.). An example would be displaying a JPEG image you found on someone else's web page so it will appear on your own site, journal, weblog, forum posting, etc.

Bandwidth refers to the amount of data transferred from a website to a user's computer. When you view a webpage, you are using that site's data transfer to display the files. Since web hosts charge based on the amount of data transferred, bandwidth is an issue. If a site is over it's monthly bandwidth, it's billed for the extra data or taken offline until the owner of the site upgrades the account.

By preventing hotlinking on your site, other sites will not be able to link to your images. If you don't prevent this and come across a site that is linking to your images, you can do a "switcheroo". (Change the image that they linked to an offensive image or one that lets them know they are hotlinking.)

To enable hotlink protection on your site, open up your .htaccess file and add the following to the next available line. (Please refer to the Introduction to .htaccess files tutorial to find out how to use and create .htaccess files.)

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

If you would like to enable hotlink protection on specific domains only, use the following code. (You will need to add each domain.)

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?othersite\.net/ [NC,OR
RewriteCond %{HTTP_REFERER} ^http://(www\.)?othersite\.com/ [NC
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]

Finally save the .htaccess and upload it to your server; most likely in the root directory. Remember that .htaccess files will apply in all subdirectories below it.



Adobe Tutorialz Photoshop Tutorials
Tutorial Man Wallpaper Stock  More