hotlink protect through .htaccess being ignored by apache

JakeSully

New member
Joined
Jan 23, 2021
Messages
4
I'm trying to hotlink protect a subdomain only, not main domain but i have no luck at all.

I have added following to file:


Code:
    RewriteEngine On
   
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https://(test\.)?domain\.com [NC]
    RewriteRule \.(jpg|jpe?g|gif|bmp|png)$ https://domain.com/404 [F,NC,L]

But it won't work when i direct visit image it still loads and i have now been googling for all kinds of solutions but it seems devs of directadmin has done something to prevent me being able to manually hotlink protect a subdomain through .htacces and doing it in panel enables hotlink protection on main domain and all subdomains, i don't want all subdomains and main domain to be hotlink protected. Only 1 single subdomain i want to be hotlink protected!

So does anyone here have solution to this?
 
Update: Do i put HTTP_HOST on first line or replace all the HTTP_REFERER?
Sorry I will test for you

go test your self
It happend on line "RewriteCond %{HTTP_REFERER} !^$"


so my code
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{HTTP_REFERER} !^https://sub\.domain\.com/.*$ [NC]
RewriteRule \.(jpg|jpeg|gif|png|bmp)$ - [F]
 
Back
Top