Forum Moderators: phranque

Message Too Old, No Replies

htaccess isn't working

         

Amanda

7:06 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



I'm trying to stop direct linking to certain images on my site, and I've uploaded an .htaccess file, but it's not working, the images can still be direct linked to. I checked with my host to make sure the server supports mod_rewrite and he said yes. So I don't know what's wrong, I've uploaded the .htaccess file to my images folder, but it doesn't work.

This is the code I'm using, I got it from HTML Basix:

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain1.net(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain2.org(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp)$ [domain1.net...] [R,NC]

RammsteinNicCage

7:47 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



Hi Amanda, let's get the easy question out of the way first: you did replace domain1.net and domain2.org with your own site's domain name, right?

Jennifer

Amanda

8:01 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



Yes, I put domain1 and domain2 there myself to abide by the rules of this forum. Oh, and the broken lines are actually supposed to be the straight up and down line.

monkeythumpa

8:25 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



How are you testing this? Are you placing a link tag linking to your images on another site, or are you just typing them into your url?

Amanda

8:40 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



I went to the page where someone is direct linking to some of my images, and I also went to HTML Basix where they have a place to check to see if images can be hotlinked. I cleared my temp internet files several times also.

Span

9:17 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure, but I think the NC flag is not allowed in a RewriteRule.
Also, you have to allow hotlinking to your bandwidth image..

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/images/bandwidth.gif$
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain1.net(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain2.org(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp)$ http://www.domain1.net/images/bandwidth.gif [R,L]