Modify the .htaccess File

The best way to do this is by modifying your .htaccess file. It should be in the main directory of web site.  Open it using your Text Editor to add the following code: RewriteCond will allow the sites (your own site URL should be here) that are able to use the images on your site. If you want to allow search engines the ability to have your images show up in the Image Search function, then add the following code: You should probably think of adding your RSS feed as well, so your images are displayed on your RSS. RewriteRule are the files that you do not want people hotlinking.

Use PHP Code

If you prefer using PHP instead. Create a new PHP file, and the following code will allow you to do the same thing as modifying the .htccess file: The first thing to do is replace ”secret-unknown-name-here” with something that no one but who you want to give access to will be able to guess. Please ensure that you create a directory of the same name.  Where it says, “http://www.yoursite.com/,” replace that with your own web site’s URL. Add the image extensions that you don’t want to allow hotlinking where you see jpg, png, and bmp. Any files that you don’t want to allow hotlinking, place it in the secret directory. The best and easiest way to prevent people from hotlinking your images is by modifying the .htaccess file. It’s quick and simple compared to coding it the PHP method. However, whatever way is up to you. On the other hand, hotlinking can be wonderful for search engine optimization (SEO), so you might not want to be too strict on this if you are practicing SEO. However, it’s really up to you how you handle hotlinking and this will help you do it. Image credit: Zemalf