Solved

Is  there a way to add an exception to a prevent hotlinking RewriteCond?

Posted on 2010-08-24
4
389 Views
Last Modified: 2016-03-18
I would like to be able to use the images on the server for my constant contact email marketing account so that anything coming from http://campaign.constantcontact.com/ would be allowed.  Below is the code I'm using in my .htaccess file from the root of my site.

Thanks for the help
Jules
#Preventing hot linking of images and other file types

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?dc-acupuncture.com/.*$ [NC]

RewriteRule \.(gif|png|jpg|js|css)$ - [F]

Open in new window

0
Comment
Question by:Jules Webb
  • 2
  • 2
4 Comments
 
LVL 26

Expert Comment

by:arober11
ID: 33525302
0
 
LVL 2

Author Comment

by:Jules Webb
ID: 33525545
Hi arober11, thanks for your reply:-)

Do you mean add another RewriteCond under the dc-acupuncture?  Obviously I don't want to block my own site.  

Also I'm wondering what the *$ [NC] means and it's not included on the constant contact url.  Since the constant contact url ends up with a whole string of trailing characters. Here is an example from the most recent newsletter:
http://campaign.constantcontact.com/render?v=001IP2wby2XJMKBMVUHbqzukjHKoH2ZeCqa3rgXkiD15O__MsOf2vqTaxmIPQvrsHcFFkA0Elx-_mdWUOqmKdRJ8ewdVbf9Y6bCbExnSkhiW6O-MYb8KVr2gpHHew6O1nH7

And image links for some reason end up like this: http://ih.constantcontact.com/fs005/1103523274156/img/7.jpg even though within constant contact the link is to the website image folder.

I appreciate you taking the time to educate me a bit:-)
Jules
#Preventing hot linking of images and other file types

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?dc-acupuncture.com/.*$ [NC]

RewriteCond %{HTTP_REFERER} !^http://campaign\.constantcontact\.com/

RewriteRule \.(gif|png|jpg|js|css)$ - [F]

Open in new window

0
 
LVL 26

Accepted Solution

by:
arober11 earned 500 total points
ID: 33526795
If "dc-acupuncture.com" also requires access, then line could read:

RewriteCond %{HTTP_REFERER}   !(dc-acupuncture|campaign\.constantcontact)\.com/   [NC]

As to what ".*$ [NC]"  signifies, the:
.*$    asks it to allow anything else up to the end of the line, and is superfluous, as it will do that anyway.
[NC]  indicates it should ignore case (NO CASE Sensitivity].

see: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
0
 
LVL 2

Author Closing Comment

by:Jules Webb
ID: 33527039
Thank You Thank You! That worked perfectly.  And thanks for the mod_rewrite link!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I want to start by talking about the use of plug-ins for WordPress. I started a web-site for a company I was working for a few years ago; I had extremely basic knowledge of HTML. I am a Graphic Designer by trade so I invited the opportunity as a cha…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now