Problem With Hot-Linking

Web hosting discussion, programming, and shared and dedicated servers.
5 posts Page 1 of 1
by ben1960 » Wed Jan 18, 2017 12:30 pm
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
by Guest » Wed Jan 18, 2017 1:17 pm
Try adding the following to the .htaccess file.

Code: Select all

Options +FollowSymLinks
by Guest » Wed Jan 18, 2017 2:56 pm
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>


by ben1960 » Wed Jan 18, 2017 7:18 pm
The above code also blocked hubrisonics.com from linking to jpg files.
by ben1960 » Thu Jan 19, 2017 10:30 pm
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]
5 posts Page 1 of 1

Who is online

In total there are 20 users online :: 2 registered, 0 hidden and 18 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: Bing [Bot], Semrush [Bot] and 18 guests