1

I'll get straight to it. I have this code in my .htaccess file to prevent hotlinking, see below:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mywebsite.ca/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://mywebsite.ca$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mywebsite.ca/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mywebsite.ca$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

but I will have a few .jpg images up for banner exchange between sites and I don't know how to write the rule to allow hotlinking for just one folder. In this case the one folder will be root/image/links/

What changes in the rewrite conditions do I need to make to allow hotlinking for this one folder?

Thanks for your anticipated help everyone.

8
  • I am aware of the method where putting another htaccess file in that folder and including RewriteEngine off but I am not sure if that will leave this folder vulnerable in some way?
    – WebEducate
    Commented May 14, 2014 at 16:36
  • try adding RewriteCond %{REQUEST_URI} !^/root/image/links/ or what ever URI is
    – Dexa
    Commented May 14, 2014 at 16:36
  • would this be correct? RewriteCond %{REQUEST_URI} !^http://www.mywebsite.ca/image/links/
    – WebEducate
    Commented May 14, 2014 at 16:40
  • 2
    RewriteCond %{REQUEST_URI} !^/image/links only.
    – Dexa
    Commented May 14, 2014 at 16:41
  • yes it worked, thank you Dexa, if you like add that response to an answer and i will check it answered.
    – WebEducate
    Commented May 14, 2014 at 16:46

1 Answer 1

5

You can use

RewriteCond %{REQUEST_URI} !^/image/links/

as an additional condition.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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