How to prevent hot linking using .htaccess?

Don’t let your users your photo steel! If you have very good photo or even not good! and want to prevent your files using php technology, such as jpg, gif, bmp, png etc.

You can just put this code in root directory of .htaccess file of your php project and it won’t let others site use you files directly and it will save your bandwidth. This is the main purpose of blocking hotlinking using .htaccess in php.


RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?my-website-url\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpg|gif|bmp|png)$ http://phpmind.com/no-hotlinking-please.png [L]

Share

Leave a Reply

Your email address will not be published. Required fields are marked *