Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-08-24
4
Medium Priority
?
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What's this? As a volunteer Page Editor for Experts-Exchange.com, I have noticed that many authors also have blogs, and pull articles from their blogs to post at Experts-Exchange. I appreciate each author sharing their blog content with our site …
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

610 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