htaccess denie only one file from referrer

125 Views Asked by At

i have a folder in which there are different images.

phpe77WUQ-155x194.jpg      
phpe77WUQ-276x345.jpg          
phpe77WUQ-84x105.jpg   
phpe77WUQ.jpg
sdfs714ggs4eg-155x194.jpg      
sdfs714ggs4eg-276x345.jpg          
sdfs714ggs4eg-84x105.jpg   
sdfs714ggs4eg.jpg

only the images with a size (e.g. 155x194) in name may be viewed from everywhere. the two other images may only be seen from referer .domain.com/user/editimage

how do i do that with htaccess?

1

There are 1 best solutions below

0
On

I hope this will work for you:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://.*\.domain\.com/user/editimage$ [NC]
RewriteRule !^(.*)-([0-9]+)x([0-9]+)\.jpg$ - [NC,L,F]

Every image without a size in its name will be blocked if the referer is not subdomain.domain.com/user/editimage