Filed under:

How to stop hotlinking on Linux accounts




In this artile there are two example, one to protect against image hotlinking and another to protect against PDF hotlinking - in all examples you will need to replace yourdomain.co.uk with your own domain making sure you enter a backslash () before any dots.


PDF Example
Create a .htaccess file in your site, or edit an existing one and enter the following

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yourdomain.co.uk/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(pdf)$ /nohotlink.pdf [L]


This will redirect any hotlinks to /nohotlink.pdf - which you could setup to explain the real PDF can be found at your own site, which may drive legit visitors to your site, Or you could setup this instead...

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yourdomain.co.uk/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(pdf)$ - [F]


Which will give a 403 forbidden error instead when hotlinking is applied.



Images Example
Create a .htaccess file in your site, or edit an existing one and enter the following

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yourdomain.co.uk/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|png)$ /nohotlink.gif [L]


This will redirect any hotlinks to /nohotlink.gif - which you could setup to explain the real image can be found at your own site, which may drive legit visitors to your site, Or you could setup this instead...

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yourdomain.co.uk/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|png)$ - [F]


Which will give a 403 forbidden error instead when hotlinking is applied.

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
article icon How to create a mailbox (Views: 2148)

Language: