Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Hot Link Protection Using htaccess  (Read 2130 times)

0 Members and 1 Guest are viewing this topic.

jominj

  • Guest
Hot Link Protection Using htaccess
« on: April 30, 2014, 06:25:17 am »
You can disable hot linking of certain file types on your site, in the case below, images, JavaScript (js) and CSS (css) files on your site. Simply add the below code to your .htaccess file, and upload the file either to your root directory, or a particular subdirectory to localize the effect to just one section of your site.

Create .htaccess file using your favourite text editor add the following code to it:
Code: [Select]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|js|css)$ - [F]

That's it we have now enabled hot link protection for the file types .gif,.jpg,.js and .css files.