3

I am using following htaccess code to stop hot linking my image files

Options +FollowSymlinks
Options +SymlinksIfOwnerMatch

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?article-stack.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
ReWriteRule .*.(png|gif|jpg)$ - [N,F,L]

Still the imge of my site are accessible from other sites. how can i stop it?

5

I think you're missing an escape for the . in your domain name:

Options +FollowSymlinks
Options +SymlinksIfOwnerMatch

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?article-stack\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
ReWriteRule .*.(png|gif|jpg)$ - [N,F,L]
  • 1
    If that were the only problem wouldn't that cause the image not to be accessible from his domain, rather than causing it to be accessible from everywhere? – BenV Oct 28 '10 at 22:12
  • good observation. But '.' refers to any single char. would it not include '.' char itself? i also support @BenV question – Amit Kumar Gupta Oct 29 '10 at 7:37
1

I tried your code on my local setup and it worked fine. It's likely that something else in your .htaccess is causing this to fail.

I notice that you are rewriting the images to http://article-stack.com/- which redirects to another page. It would be best to rewrite to another image or to a 404 error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.