Golpo Community Forum
Golpo Podcast

Go Back   Golpo Community Forum > Misc. > Tech-Talk & Technical Help

Tech-Talk & Technical Help Talk & Ask Anything About Technology.

Reply
 
LinkBack (6) Thread Tools Display Modes
  6 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 05-19-2007, 12:23 AM
Icy's Avatar
Icy Icy is offline
bujhchi!!!
Developer
Gender: Male
My System
 
Posts: 21,985
Threads: 291
Last Online: 07-06-2008 10:53 PM
Join Date: Dec 2005
Location: /dev/null/
Send a message via MSN to Icy
Exclamation Webmaster's Tutorial: Prevent Hotlinking for Apache Web Server


"Hotlinking" is a form of bandwidth theft. Basically, when creating a web page it is easy to link to a file (such as an image or a video) that exists on a remote (completely separate) site. Each time the web page is accessed, the file is retrieved from the remote web site.

Consider this example: You have created a personal gallery of cherished images. Someone else likes one of your images, so they post a "hotlink" to that image on a popular forum that they visit. Now that image is plucked from your web server every single time that page of the forum is viewed. It can quickly add up to thousands of requests, eating into your precious bandwidth allocation. To make matters worse, the image is so popular that it begins to appear in several other forums.

How can hotlinking be prevented?

There are several ways you can prevent hotlinking, but the best involve adding lines to your .htaccess file. If you do not already have an .htaccess file, you can create one in a text editor - note the strange filename .htaccess. In the code below, your domain is assumed to be www.example.com. You will need to change the code to reflect your own domain name. Please note: this technique will only work on the Apache web server.

Replacing Images

Deny All Remote Servers:

The following code will cause the remote server to display no_hotlink.jpg instead of the requested image:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteCond %{HTTP_REFERER} ^http:// [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|png)$ images/no_hotlink.jpg [R,L]
Where, NC = No Case, R = Redirect & L = Last.

Allow Hotlinking from Only a Specified Directory:

The following code will cause the remote server to display 'no_hotlink.jpg' instead of the requested image, unless the image has been requested from a specified directory (dir):
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/dir/ [NC]
RewriteCond %{HTTP_REFERER} ^http:// [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpeg|gif|png)$ images/no_hotlink.jpg [R,L]
Allow Hotlinking to All But Specified Domains:

The following code will cause the remote server to display no_hotlink.jpg instead of the requested image, but only when the image has been requested by badsite.net or badsite.com:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.net/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.com/ [NC]
RewriteRule \.(jpe?g|gif|png)$ images/no_hotlink.jpg [R,L]
Preventing Bandwidth Theft
Instead of replacing the image, these methods will simply deny the remote domain access to the images altogether, thus preventing any bandwidth theft.

Blocking All Domains:

The following code will return a 403 Forbidden error instead of the requested image:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteCond %{HTTP_REFERER} ^http:// [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|png)$ - [F]
Blocking Specific Domains:

The following code will return a 403 Forbidden error instead of the requested image, but only when the image has been requested by badsite.net or badsite.com:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.net/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.com/ [NC]
RewriteRule \.(jpe?g|gif|png)$ - [F]
Golpo is using the following code for prevent hotlinking .
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.golpo.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.golpo.net$ [NC]
RewriteRule .*\.(mp3|mpeg|mpg|ram|rm|wma|wav|asx|wmv|avi|mov|zip|rar|exe)$ http://www.golpo.net/forum/ [R,NC]

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.golpo.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.golpo.net$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf)$ http://www.golpo.net/forum/ [R,NC]


Collected


Gaaner Ami Tumi Hariye Jabo
Reply With Quote
  #2 (permalink)  
Old 05-29-2007, 06:33 PM
Nneel's Avatar
Nneel Inside.
Administrator
Gender: Male
My System
 
Posts: 3,265
Threads: 127
Last Online: 07-06-2008 06:32 PM
Join Date: Dec 2005
Location: Nneel's Planet.
Blog Entries: 12
Send a message via MSN to Nneel
Default


its nice...

els this u can send any custom msg/image to hotlinker ..
but its not wise coz its sending something..

thnx for it



- [ Nneel. ]-

Walk a few milez for a little far...Its a long road when u run it own..
Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 04:40 AM
Bristir Chhonde's Avatar
G. Immortal
Gender: Female
 
Posts: 3,841
Threads: 61
Last Online: 07-03-2008 10:03 PM
Join Date: Apr 2007
Location: Meghla Megher Deshe, Bristi Hoye Pori Seshe :)
Blog Entries: 4
Default


very informative..thanks bhaiaa
kaje ashbe


Reply With Quote
Sponsored Links
  #4 (permalink)  
Old 06-29-2007, 04:45 AM
Pain man's Avatar
Illuminatus
Gender: Male
 
Posts: 1,661
Threads: 31
Last Online: 07-05-2008 12:47 PM
Join Date: Jan 2007
Location: 5-3-2-1-1
Send a message via MSN to Pain man
Default


nice share


manush re pain den nije shanti pan
Reply With Quote
Reply

Sponsored Links

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.golpo.net/forum/f36/webmasters-tutorial-prevent-hotlinking-apache-web-server-7022/
Posted By For Type Date
Digg - Webmaster's Tutorial: Prevent Hotlinking for Apache Web Server This thread Refback 06-05-2007 07:20 PM
Digg / Security / Upcoming This thread Refback 05-29-2007 08:06 PM
Digg / Technology / Upcoming This thread Refback 05-29-2007 08:02 PM
Digg / News / Upcoming This thread Refback 05-29-2007 06:54 PM
Digg / News / Upcoming This thread Refback 05-29-2007 06:43 PM
Digg / Technology / Upcoming This thread Refback 05-29-2007 06:39 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webmaster's Article: Google Icy Tech-Talk & Technical Help 9 05-19-2007 01:25 AM
Webmaster's Tutorial: Installing Apache, PHP and MySQL on Windows Icy Tech-Talk & Technical Help 8 05-01-2007 02:37 AM
Webmaster's Tutorial: XHTML Icy Tech-Talk & Technical Help 7 04-26-2007 03:41 PM
Windows Vista - Download Now - Fast Server Patcher Software Review 5 09-30-2006 07:39 PM
Host Server Upgraded Nneel News & Announcements 0 06-09-2006 12:54 PM



All times are GMT +7. The time now is 07:27 AM.

Copyright ©2003 - 2008, Golpo Community. All Rights Reserved.
Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Islamicvdos.com | Your Ads Here
McDonalds | Comcast | Download MP3 Services | MySpace Images | Loans