I am trying to prevent hot linking of images on our site. I have tried editing
/etc/httpd/conf/httpd.conf by adding the following to the end of the file:
<VirtualHost *:80>
ServerName www.myserver.co.uk
ServerAlias myserver.co.uk
DocumentRoot /var/www/html/www.myserver.co.uk
ServerPath /www.myserver.co.uk
SetEnvIfNoCase Referer "myserver’.co.uk" local_ref=1
<FilesMatch "’.(gif|jpg|jpeg|png)">
Order Allow,Deny
Allow from env=local_ref
</FilesMatch>
But this does not seem to prevent hot linking. I know I can also prevent hot-linking from within the .htaccess file, but wanted to know why my attempt to do it via the httpd.conf file is failing?
I have also tried:
SetEnvIfNoCase Referer "^http://www\.myserver\.co\.uk/" banimages=1
SetEnvIfNoCase Referer "^http://myserver\.co\.uk/" banimages=1
SetEnvIfNoCase Referer "^$" banimages=1
<FilesMatch "\.(gif|png|jpe?g)$">
Order Allow,Deny
Allow from env=banimages=1
</FilesMatch>
Which did not work either. What I am doing wrong?
EDIT: I have not also tried the following 4 lines at the end of the httpd.conf file as is, without placing them in any tag like the virtualhost tag:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !=""
RewriteCond %{HTTP_REFERER} !mysite\.co\.uk [NC]
RewriteRule \.(jpe?g|gif|png)$ - [F,NC]
The images still seem hotlinkable.