Search code examples
.htaccessmod-rewritehotlinking

using hotlink prevention


I'm wondering how to target the picture in this following code:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://dooomain.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://www.dooomain.com/.*$ [NC]
RewriteRule .*.jpg$ -                           [L]

not really sure where I have to insert the jpg file!! is it in the web root folder or where?

Thanks

Update #1

ok, maybe I found something to my answer, but not sure so please guys correct me if I'm wrong...

here is the code I should add instead of the last line in my main post:

RewriteRule \.(gif|jpg)$ https://www.mydooomain.com/pic.gif [R,L]

and I need to place the picture in the root in this case, is that right???

Thanks


Solution

  • The last rule above is fine. But rewritecond can be done in a single line.

    RewriteCond %{HTTP_REFERER} !^(?:$|http://domain.com|http://www.domain.com) [NC]
    RewriteRule \.(gif|jpg)$ https://www.mydomain.com/pic.gif [R,L]