Hotlink protection but no subdomains

If its in your parent public_html folder it will work with all subdomains in there.
 
If its in your parent public_html folder it will work with all subdomains in there.

http://sub.maindomain.com can't load images is protected by hotlink

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?maindomain.com [NC]
RewriteRule \.(jpg|jpeg|png)$ https://www.maindomain.com/stealingisbad.png [NC,R,L]

subdomains is by wordpress blog created
 
You would have to add another line for your subdomain like this:

Code:
RewriteCond %{HTTP_REFERER} !^http(s)?://(sub\.)?maindomain.com [NC]

So that it looks like:

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?maindomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(sub\.)?maindomain.com [NC]
RewriteRule \.(jpg|jpeg|png)$ https://www.maindomain.com/stealingisbad.png [NC,R,L]
 
You would have to add another line for your subdomain like this:

Code:
RewriteCond %{HTTP_REFERER} !^http(s)?://(sub\.)?maindomain.com [NC]

So that it looks like:

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?maindomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(sub\.)?maindomain.com [NC]
RewriteRule \.(jpg|jpeg|png)$ https://www.maindomain.com/stealingisbad.png [NC,R,L]

Thank you i have 1000+ subdomains "http(s)?://(sub\.)?maindomain.com" support all?
 
Try this instead:

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://*.maindomain.com [NC]
RewriteRule \.(jpg|jpeg|png)$ https://www.maindomain.com/stealingisbad.png [NC,R,L]
 
maybe

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?maindomain.com [NC]
RewriteRule \.(jpg|jpeg|png)$ https://www.maindomain.com/stealingisbad.png [NC,R,L]
 
maybe

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?maindomain.com [NC]
RewriteRule \.(jpg|jpeg|png)$ https://www.maindomain.com/stealingisbad.png [NC,R,L]

many thanks working. good luck Arieh, scsi
 
Back
Top