blacklotus Posted March 10, 2009 Share Posted March 10, 2009 Okay... I'm getting really frustrated with this one and hope someone can help me. I want to prevent hotlinking to images on www.vortexaviation.ca, and for this I'm using mod_rewrite (or at least I'm trying) I have one image I want to use as a hotlink substitute (I want to show this instead of any image an external site would link directly). This is the image: http://www.vortexaviation.ca/images/nohotlinking.gif (If you can see the image below and it's showing a NO HOTLINKING icon, it's working now... if it's broken, is not showing anything or you see a Flightstar logo, I still need help) ---> <--- I read MANY tutorials on how to do it, and ended up with the following .htaccess file (located in my HTTP_ROOT) Options +FollowSymlinks # no hot-linking RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?vortexaviation\.ca/ [NC] RewriteCond %{HTTP_REFERER} !google\. [NC] RewriteCond %{HTTP_REFERER} !search\?q=cache [NC] RewriteRule .*\.(gif|jpg|png)$ http://www.vortexaviation.ca/images/nohotlinking.gif [NC] It's blocking the image fine, but it won't replace it with my substitution! All it does is create a broken image icon. You can see a test I'm doing from another one of my sites at http://vortexaviation.black-lotus.net/test.php The image should appear above the "Test referer" link (which directs to another page so I can debug the HTTP_REFERER string). Can anyone see something wrong? Would there be something not enabled on my server? I'm using the Economy Linux Hosting plan from godaddy.com and the domain is not a subdomain. Quote Link to comment Share on other sites More sharing options...
blacklotus Posted March 11, 2009 Author Share Posted March 11, 2009 ...Now it creates an internal server error if I try to open the nohotlinking.gif file directly... Quote Link to comment Share on other sites More sharing options...
blacklotus Posted March 11, 2009 Author Share Posted March 11, 2009 I FIXED IT! The code I was using was creating an infinite redirect loop. So I added a RewriteCond to exclude the nohotlinking.gif file... It's sad no tutorial I read about mod_rewrite said anything about that problem though... This is my final code: Options +FollowSymlinks # no hot-linking RewriteEngine On RewriteCond %{REQUEST_URI} !nohotlinking.gif$ RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?vortexaviation\.ca/ [NC] RewriteCond %{HTTP_REFERER} !google\. [NC] RewriteCond %{HTTP_REFERER} !search\?q=cache [NC] RewriteRule .*\.(gif|jpg|png)$ http://www.vortexaviation.ca/images/nohotlinking.gif [R,NC] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.