Page 1 of 1

Problem With Hot-Linking

Posted: Wed Jan 18, 2017 12:30 pm
by ben1960
Hello,

The following .htaccess file, which resides on the Sonic server, does not block hot-linking from an HTML file on my desktop.

Code: Select all


Action php-cgi /cgi-bin/php55
   AddHandler php-cgi .php 
   
<IfModule mod_rewrite.c>    
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?hubrisonics.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?duckduckgo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|m4a)$ - [NC,F,L]
</IfModule>

When the same .htaccess file is on my local host, it works for blocking my local host from displaying jpg files with the “img” tag. This means that the problem must be with the Sonic server. Can anybody help with this problem?

Regards,

HubriSonics

Re: Problem With Hot-Linking

Posted: Wed Jan 18, 2017 1:17 pm
by Guest
Try adding the following to the .htaccess file.

Code: Select all

Options +FollowSymLinks

Re: Problem With Hot-Linking

Posted: Wed Jan 18, 2017 2:56 pm
by Guest
You may also need the OR logic vs implicit AND since there are multiple RewriteCond(s) so you could try this also.

Code: Select all

Action php-cgi /cgi-bin/php55
   AddHandler php-cgi .php 
   
<IfModule mod_rewrite.c>    
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [OR]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?hubrisonics.com [NC,OR]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?duckduckgo.com [NC,OR]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC,OR]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC,OR]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|m4a)$ - [NC,F,L]
</IfModule>



Re: Problem With Hot-Linking

Posted: Wed Jan 18, 2017 7:18 pm
by ben1960
The above code also blocked hubrisonics.com from linking to jpg files.

Re: Problem With Hot-Linking

Posted: Thu Jan 19, 2017 10:30 pm
by ben1960
Here is the code that solved the problem.

Code: Select all

Action php-cgi /cgi-bin/php55
   AddHandler php-cgi .php

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?hubrisonics.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?duckduckgo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|m4a)$ - [NC,F,L]