You are Here:
FAQ
Scripting and Programming Languages
Configuring Apache Webserver using .htaccess
Article #9
|
What is hotlinking?What is hotlinking? Hotlinking is when another web site owner links directly to one or more of your images or multimedia files and includes it on their web page. Hotlinking is when other people use your files directly pulled from your site, meaning each time the file is viewed through their site, it comes out of your Bandwidth, in the end this means that you could end up paying for the bandwidth. On Linux packages there is an easy solution. 1&1 has the Rewrite Engine activated. This means that you can set it up to analyze any incoming request for a file and deal with them appropriately. Do the following; Create a .htaccess file, then add the following code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain_name/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain_name/.*$ [NC] [OR]
RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg)$ - [F]
This will only allow your sites to display your images and multimedia files The Code Explained
Line 1 : This Turns the RewriteEngine on. Line 2 : ^ = Begin $ = End of Line Line 3 : Allows request from http://your_domain_name/. [NC] = Not Continue [OR] = or Line 4 : Allows request from http://www.your_domain_name/ Line 5 : Applies the rule to specific File Formats [F] = Finish Note: To get the | symbol, you will need to do shift + \ , normally located in the bottom left of your key board You can also add other site that are not yours, that you wish to allow to share images, see the code below:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain_name/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain_name/.*$ [NC] [OR]
#Trusted Sites - Add Here!!!!
RewriteCond %{HTTP_REFERER} !^http://www.trusted_sites_1/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://trusted_sites_1/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.trusted_sites_2/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://trusted_sites_2/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://trusted_sites_x/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.trusted_sites_x/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg)$ - [F]
Note: Place the .htaccess file in the directory your domain is pointing to. Disclaimer: 1&1 provides the scripts and related information on this page as a courtesy, subject to 1&1's General Terms and Conditions of Service (the "GT&C"). As set forth in more detail in the GT&C, the scripts and information are provided "as-is", without any warranty, and 1&1 is not liable for any damages resulting from your use of the scripts or information. |
© 2008 1&1 Internet Inc - About 1&1 Internet