Needless to say why to block the image hotlink from a site, simply because of the need to prevent someone to steal its bandwidth (thus save the extra money for the webhosting).
Wordpress gurus please ignore this entry, as the post here is only intended for those newbies who just host their wordpress.org-supported blogs on a web host and want prevent other bloggers hotlinking their images.
Follow the steps below and make your images only available to your own site and let search engines, like Google, Yahoo and Msn, to index.
- Log in your FTP client, here we recommend to use FileZilla (it’s open source, and versatile)
- Locate “Server” menu, and click “Force showing hidden files”
- Doube-click the the site root directory in the FileZilla panel, like this site, it’s hollywoodcelebgossips.com.
- Find a file named .htaccess
- Download it to the desktop and open it using Notepad, you are now getting the default Wordpress .htaccess file.
- Insert the code in Step 7 below the line of “
RewriteRule . /index.php [L]"obtained from the default file in this step. -
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpe?g$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !hollywoodcelebgossips\.com [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]
- Say if your URL is www.example.info, replace “hollywoodcelebgossips” and “com”, with “example” and “info”, respectively, in the fourth line of the code above.
- Save .htaccess file in Notepad and upload it to your site root directory in FileZilla panel.
- When prompted if to overwrite the existing file with the same name, click “Yes” in the pop-up window.
- You make it! The images will only appear on your own site, RSS readers and some time later search engines’ image search will bring you the traffics.
If wanna know how to tweak .htaccess file for non-wordpress supported blogs/sites, please visit WalkerNews.net’s Image Hotlinking Prevention With Apache Mod_Rewrite which is also the inspiration of writing up this tip.
