title: How to implement .htaccess hotlink protection
body: <p>I'm trying to implement some protection of my images, what's wrong with my code?    </p>
  
  <pre><code>// If referral is from google but NOT from "http://www.google.com/blank.html", redirect home
  RewriteCond %{HTTP_USER_AGENT} !(googlebot|bingbot|Baiduspider) [NC]  //If user agent is NOT bot
  RewriteCond %{HTTP_REFERER} !^$                                       //Allow blank referral
  RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]      //if referral is from google
  RewriteCond %{HTTP_REFERER} ^http://www.google.com/blank.html$        //if referral is NOT from that url
  RewriteRule  http://www.mydomain.com/ [R,L]                           //redirect home
  
  
  // If referral is from my domain and accessing images, do nothing
  RewriteCond %{HTTP_USER_AGENT} !(googlebot|bingbot|Baiduspider) [NC] //If user agent isn't bot
  RewriteCond %{HTTP_REFERER} !^$                                      //Allow blank referral
  RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC]   //if referral is from my domain
  RewriteCond %{REQUEST_URI} !(^|&amp;)images(&amp;|$)                         //if URL contains string "images"
  RewriteRule ^.*$ - [NC,L]                                            // DO nothing 
  
  
  // If referral is NOT from my domain and accessing images, show watermarked image
  RewriteCond %{HTTP_USER_AGENT} !(googlebot|bingbot|Baiduspider) [NC] //If user agent isn't bot
  RewriteCond %{HTTP_REFERER} !^$                                      //Allow blank referral
  RewriteCond %{HTTP_REFERER} mydomain.com                             //if referral is NOT from my domain
  RewriteCond %{REQUEST_URI} !(^|&amp;)images(&amp;|$)                         //if URL contains string "images"
  RewriteRule ^images/(.*)$ http://www.mydomain.com/cache/$1 [NC,R,L]  //redirect to watermarked image
  </code></pre>
  
  <p>I'm pretty much trying to create Step 2 of <a href="https://stackoverflow.com/a/14860184/1992125">this answer</a>, but I'm having trouble with the "Equal to" and "Not equal to" as I come from php and ! operator is used for Not equal to.</p>
  
  <p>Help someone?</p>