<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NerdGrind - How-to Computer Help - Tutorials - Tech and Gadget News &#187; hotlinking</title>
	<atom:link href="http://www.nerdgrind.com/tag/hotlinking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdgrind.com</link>
	<description>Gadget and technology news, computer help, and how-to tutorials on everything, from your friendly nerd at NerdGrind</description>
	<lastBuildDate>Tue, 17 Nov 2009 20:03:16 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Block Hotlinking with Apache Web Server</title>
		<link>http://www.nerdgrind.com/block-hotlinking-with-apache-web-server/</link>
		<comments>http://www.nerdgrind.com/block-hotlinking-with-apache-web-server/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 00:24:52 +0000</pubDate>
		<dc:creator>Nerd Grind</dc:creator>
				<category><![CDATA[How to Apache]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[hotlink]]></category>
		<category><![CDATA[hotlinking]]></category>
		<category><![CDATA[How to Linux]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[image stealing]]></category>
		<category><![CDATA[image theft]]></category>
		<category><![CDATA[OLED]]></category>

		<guid isPermaLink="false">http://www.nerdgrind.com/block-hotlinking-with-apache-web-server/</guid>
		<description><![CDATA[<img src="http://images.nerdgrind.com:9000/images/icons/apache-2.png" width="79" height="25" alt="apache 2 Block Hotlinking with Apache Web Server"  title="Block Hotlinking with Apache Web Server" /><br/>Many web site owners have a hosting or co-location plan that limits the amount of bandwidth their web site can use each month. With the proliferation of user spaces on sites such as MySpace, Facebook, etc, people using those services, as well as other web site owners, copy the code for an image from your [...]]]></description>
			<content:encoded><![CDATA[<img src="http://images.nerdgrind.com:9000/images/icons/apache-2.png" width="79" height="25" alt="apache 2 Block Hotlinking with Apache Web Server"  title="Block Hotlinking with Apache Web Server" /><br/><p>Many web site owners have a hosting or co-location plan that limits the amount of bandwidth their web site can use each month. With the proliferation of user spaces on sites such as MySpace, Facebook, etc, people using those services, as well as other web site owners, copy the code for an image from your web site, and put it into a page on their site. This means that each time that person&rsquo;s page loads for a reader, the image comes from your server, and uses your bandwidth to serve it. This practice is called <strong>hotlinking</strong>. The bandwidth you purchase can get chewed up in a hurry if too many people do this to you. Fortunately there is a solution.</p>
<p>This tutorial applies to <strong>Apache</strong> web server only.</p>
<p><span id="more-3022"></span></p>
<p>There are two ways to block hotlinking. First by using the httpd.conf file, and second by using the .htaccess file.</p>
<p><strong>Option 1:</strong></p>
<p>Using the main httpd.conf file for Apache uses fewer resources, and will be applied to all web sites on the server, so we&rsquo;ll start there. Using a bash shell type:</p>
<p>
<pre class="brush: php;">vi /etc/httpd/conf/httpd.conf</pre>
</p>
<p>First be sure your httpd.conf contains the following line with no # sign in front of it. The line should look like the one below:</p>
<p>
<pre class="brush: php;">LoadModule setenvif_module modules/mod_setenvif.so</pre>
</p>
<p>Rather than using your arrow key you can page down in vi, you can use ctrl + d to reach the end of the httpd.conf file. At the end of your config file you&rsquo;ll need to add the following code. </p>
<p>
<pre class="brush: php;">&lt;VirtualHost *:80&gt;
SetEnvIfNoCase Referer &quot;mydomain’.com&quot; local_ref=1
&lt;FilesMatch &quot;’.(gif|jpg|jpeg|png|swf|mpg|avi|flv)&quot;&gt;
Order Allow,Deny
Allow from env=local_ref
&lt;/FilesMatch&gt;
&lt;/VirtualHost&gt;</pre>
</p>
<p>The new VirtualHost container should look something like this:</p>
<p>
<pre class="brush: php;">&lt;VirtualHost *:80&gt;
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/mysitedirectory
ServerPath /mysitedirectory
SetEnvIfNoCase Referer &quot;mydomain’.com&quot; local_ref=1
&lt;FilesMatch &quot;’.(gif|jpg|jpeg|png|swf|mpg|avi|flv)&quot;&gt;
Order Allow,Deny
Allow from env=local_ref
&lt;/FilesMatch&gt;
&lt;/VirtualHost&gt;</pre>
</p>
<p>You can add as many different file types to the list as you want. Just be sure each file is separated by a pipe |. To close and save the changes made by vi type:</p>
<p>
<pre class="brush: php;">:wq</pre>
</p>
<p>and hit enter.</p>
<p>Suppose you wanted to add more trusted domains besides your own. You could add:</p>
<p>
<pre class="brush: php;">SetEnvIfNoCase Referer &quot;trusted-domain’.com&quot; trusted=yes
SetEnvIfNoCase Referer &quot;another-trusted-domain’.com&quot; trusted=yes
Allow from env=trusted</pre>
</p>
<p>Your new code would then would include your own domain, and other trusted domains. The new code would look like the following below:</p>
<p>
<pre class="brush: php;">&lt;VirtualHost *:80&gt;
SetEnvIfNoCase Referer &quot;mydomain’.com&quot; local_ref=1
SetEnvIfNoCase Referer &quot;trusted-domain’.com&quot; trusted=yes
SetEnvIfNoCase Referer &quot;another-trusted-domain’.com&quot; trusted=yes
&lt;FilesMatch &quot;’.(gif|jpg|jpeg|png|swf|mpg|avi|flv)&quot;&gt;
Order Allow,Deny
Allow from env=local_ref
Allow from env=trusted
&lt;/FilesMatch&gt;
&lt;/VirtualHost&gt;</pre>
</p>
<p><strong>Option 2:</strong></p>
<p>The less efficient, but possibly more useful option is to use the use the .htaccess file. For Wordpress users you can access the .htaccess file from your administrative control panel by going to manage &#8211;&gt; files &#8211;&gt; .htaccess (for rewrite rules ). For others type the following into a bash shell:</p>
<p>
<pre class="brush: php;">vi /var/www/mysitedirectory/.htaccess</pre>
</p>
<p>Add the following code:</p>
<p>
<pre class="brush: php;">&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
# Hotlink Protection with Feedburner Access Start
RewriteCond %{REQUEST_FILENAME} ’.(gif|jpg|jpeg|png|swf|mpg|avi|flv|mp3)$ [NC]
# Next line allows a blank or empty referrer to see images
# this includes people simply pasting the url to the image and going to it
# this line is necessary for some with firewalls, ISP firewalls, even AOL
# norton and mcafee personal firewall remove REFERER header
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !mydomain’.com [NC]
# The line below is a way to allow all of feedburner.com
# RewriteCond %{HTTP_REFERER} !feedburner’. [NC]
# It is better to only specify your direct feed
RewriteCond %{HTTP_REFERER} !^http://feeds.feedburner.com/mywebsite$ [NC]
RewriteCond %{HTTP_REFERER} !google’. [NC]
## RewriteCond %{HTTP_REFERER} !bloglines’. [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/ [R=301,L]
&lt;/IfModule&gt; # If this line is already present, as in Wordpress, then do NOT add
# Hotlink Protection with Feedburner Access End</pre>
</p>
<p>To close and save the changes made by vi type:</p>
<p>
<pre class="brush: php;">:wq</pre>
</p>
<p>and hit enter.</p>
<p>Whenever you see a # in, or at the start of, a line, anything after the # will not be read by Apache. Using # is referred to as commenting out the line or text. You can use more than one # to comment out a line. Wordpress already has &lt;/IfModule&gt; at the end of the .htaccess file, so adding and extra &lt;/IfModule&gt; could cause a problem.</p>
<p>If you make an error, and you get a 500 error instead of seeing your site type the following into your bash shell:</p>
<p>
<pre class="brush: php;">vi /var/www/mysitedirectory/.htaccess</pre>
</p>
<p>Now type</p>
<p>dd</p>
<p>To erase each line of code you added. Remember to type :wq to close and save your work. Always make a backup of the .htaccess file before you start.</p>
<p>An easier way to access these files on a dedicated server is using an administrative control panel, which I will discuss in a later article.</p>
<p>Be sure to save your .htaccess file after make changes. Some plugins for Wordpress, as an example, can overwrite your .htaccess file. After making changes with a plugin, etc., it&rsquo;s good practice to check and make sure your .htaccess file has not changed.</p>
<p>Some people serve another image that says NO HOTLINKING, but that is still using bandwidth, so my configuration serves nothing. On the thief&rsquo;s end, readers will see a read X in Internet Explorer, but no image.</p>
<p>One last note, you cannot use option 1 and 2 together. You have to choose and use only option 1, or only option 2. Apache may not give you an error in the log, but it could drag down Apache&rsquo;s performance with an incorrect configuration.</p>
<p><b>&copy; Copyright <a href="http://www.nerdgrind.com/" >NerdGrind</a> 2009. All Rights Reserved.</b></p><p>
	<h4>Related posts:</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.nerdgrind.com/how-to-increase-screen-size-or-resolution-in-virtualbox-for-ubuntu-or-linux/" title="How to Increase Screen Size or Resolution in Virtualbox for Ubuntu or Linux">How to Increase Screen Size or Resolution in Virtualbox for Ubuntu or Linux</a></li>
	<li><a href="http://www.nerdgrind.com/samsung-unveils-flexible-oled-concept-phone-video/" title="Samsung Unveils Flexible OLED Concept Phone &#8211; Video">Samsung Unveils Flexible OLED Concept Phone &#8211; Video</a></li>
	<li><a href="http://www.nerdgrind.com/prada-announces-prada-ii-phone-will-accompany-bluetooth-watch/" title="Prada Announces Prada II Phone Will Accompany Bluetooth Watch">Prada Announces Prada II Phone Will Accompany Bluetooth Watch</a></li>
	<li><a href="http://www.nerdgrind.com/fcc-documents-announce-that-nokia-n85-coming-to-north-america/" title="FCC Documents Announce that Nokia N85 Coming to North America">FCC Documents Announce that Nokia N85 Coming to North America</a></li>
	<li><a href="http://www.nerdgrind.com/casio-81-megapixel-w63ca-480-x-800-pixel-oled-only-in-japan/" title="Casio 8.1 Megapixel W63CA &#8211; 480 x 800 Pixel OLED &#8211; Only in Japan">Casio 8.1 Megapixel W63CA &#8211; 480 x 800 Pixel OLED &#8211; Only in Japan</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.nerdgrind.com/block-hotlinking-with-apache-web-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!--
This site's performance optimized by W3 Total Cache:

W3 Total Cache improves the user experience of your blog by caching
frequent operations, reducing the weight of various files and providing
transparent content delivery network integration.

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 19/34 queries in 0.255 seconds using memcached

Served from: carsndealerships.com @ 2009-11-21 10:33:48 -->