Walker News

Image Hotlinking Prevention With Apache Mod_Rewrite

It takes less than few minutes to setup a weblog in WordPress or New Blogger, but it takes incalculable seconds or endless time of a REAL BLOGGER to maintain the blog – other than spending time to write your very OWN posts, it takes your valuable time to deal with some thorny issues of blogging, such as plagiarism, bandwidth theft, web site hijacking, comment spam, etc!

After the sadness fact of WalkerNews.net being splogged, I’ve just realized that the Apache mod_rewrite module doesn’t works on image hotlinking prevention to safeguard my web hosting bandwidth usage – unknown to me that the .htaccess file has been reverted to the WordPress default – and thus the Sploggers are also bandwidth thieves of WalkerNews.net!
Not everyone can be a Nobel prize writer, including this poor writer in WalkerNews.net. But, I’m a REAL BLOGGER who spending time to think and write for the respect and honour (trying hard). However, a SPLOGGER is an evil who copy and paste the REAL BLOGGER posts completely on their own Splog – they don’t write, but steal – and thus gaining negative respect and dubbed that infamous title (Splogger – the cancers of Web 2.0)!

How to stop bandwidth theft by enabling the image hotlinking prevention feature of Apache mod_rewrite module?

Locate the the .htaccess file (i.e. using ls -la Linux command) in the root directory of your web site or weblog.

If the file is not currently exists, create the .htaccess file (i.e. type touch .htaccess in the website/weblog root directory) and write these lines in the .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpe?g$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !walkernews\.net [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !live\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteCond %{HTTP_REFERER} !msn\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule .* - [F]

where
  • RewriteEngine On is to turn on Apache Rewrite engine for the mod_rewrite module (the mod_rewrite module must has been installed).
     
  • RewriteCond %{REQUEST_FILENAME} specify all the image formats (the images file extension) used in your web site or weblog that you want to prevent image hotlinking.
     
  • The [NC] is simply means “no case-sensitive” – to ignore lower and uppercase.
     
  • RewriteCond %{HTTP_REFERER} tells mod_rewrite to ONLY allow the specified web sites / referrals perform image hotlinking, e.g. your own web site (in this example, it’s walkernews\.net, which should be replaced with your own weblog URL), Google Web Search (including image search, etc), Live Search, Yahoo! Search, and the page caches (the !search\?q=cache), etc.
     
  • RewriteRule .* - [F] instructs mod_rewrite module to disable image hotlinking, whenever an image request to appears on the sites that are not specified in those RewriteCond %{HTTP_REFERER} lines.

For WordPress weblogs that display human-readable permanent links, the .htaccess should has been created and filled with these similar content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

In this case, you just need to append the block of “image hotlinking prevention” lines after the RewriteRule . /index.php [L] line.
With reference to Smarter Image Hotlinking Prevention @ A List Apart of Thomas Scott and How Do I Stop Hotlinking and Bandwidth Theft @ AltLab.

Custom Search

  1. Disable Wordpress Directory Listing In Web Browser » Walker News 10-08-07@00:31

    [...] is the wonderful of Apache web server! If you’re a junior webmaster, please also confirm the image hotlinking prevention feature has been turned on to stop the bandwidth [...]

  2. Highlight Author Comment And Pingback In Wordpress Theme – Walker News 30-10-07@18:16

    [...] simple CSS hack is still possible to highlight author’s comments and pingbacks. (There is NO bandwidth overhead on web-hosting by turning on Gravatar as the graphics is stream from Gravatar servers! So, why [...]

  3. How To Embed FLV Flash In WordPress or HTML 28-06-09@18:06

    [...] to your post without replace the colourized-text. It won't work in that way, because I disable the hotlinking to prevent you and most other people from using my hosting bandwidth :-) (This FLV video is [...]

  4. How To Embed SWF In HTML Code Or WordPress Post? 18-07-09@01:42

    [...] simply copy and paste this template code without updating the SWF’s web path, as the hotlinking prevention will stop it from working on your [...]

2014  •  Privacy Policy