Trouble with getting my .htaccess to work


Bandwidth stealing is becoming an issue with my server and I have read up on making a .htaccess file to help prevent the hotlinking. But I am having some trouble getting the the .htaccess file to work. To give some background information: I use WS_FTP Professional to upload my files and I can view my .htaccess in the FTP. I made the .htaccess file in NotePad and it looks as such:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(. .) [NC]
RewriteCond %{HTTP_REFERER} !^http://(. .) [NC]
RewriteCond %{HTTP_REFERER} !^http://(. .) [NC]
RewriteCond %{HTTP_REFERER} !^http://(. .) [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(gif|jpg|jpeg|png|bmp|mp3|mid|midi|html)$ [L]

I change my WS_FTP to ASCII mode, change the CHMOD to the specific properties, and I uploaded the .htaccess to three directories in general. The main one, the “” directory, and the “” directory. The main directory I want to focus on is my “” directory because that is where most people are hotlinking from. I have already read up on the DreamHost Wiki and even use Google, and they don’t seem to help me any. I check my files using:

And I have also tried using the Goodies > Htaccess/WebDAV in my Web Panel and they don’t work at all.

So I hope someone here can figure out why its not working for me and I thank you in advance for reading this.

~ enigmaopoeia


You forgot to mention whether or not you cleared your browser cache. You did see the notice on that web site, right?

(Don’t forget to refresh and clear your browser cache to prevent your image from loading from your local hard drive instead of the server you are testing. Consult your browser documentation for further info on clearing your browser cache.)

For testing hotlinks, you’re better of using something like or your own script.

:cool: -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


Thanks for the response, Atropos7!

Yeah, I have cleared my browser’s cache. Yet they still show my images and not the hotlink image I’ve provided. And I have tried out that Web Sniffer link previous to my topic and it doesn’t seem to be helping me much. =/


Well, setting aside that it seems like you could accomplish this with a much simpler regular expression, I think the problem might be that the regex you’ve got there are wrong. I’m not sure if it’s what you typed into the forum or if it’s actually what’s there, but if it’s actually what’s there, I definitely don’t see how they would work at all.

What I’m looking at in particular is the (. .) construct you’ve got near the start of each URL. In your rules, is that really open-paren, dot, space, backslash, dot, close-paren?

If so, then that means you’re telling it to match http://, followed by any character, followed by a space, followed by a dot, followed by the rest of your URL. In all probability, that is not what you want to do.

Something like this might work out better: !^http://(www\.)?(dcj\.)?bluemoonsea\.com/


Why is it not helping you much? What do you mean by that?

Obviously if I pull a link to an image on your site and submit it to web-sniffer I should get the redirect. Let us try it on the following image:

Web-Sniffer results for clocktower3_15_800x600.jpg

Currently I am getting the ‘302 Found’ redirect to your hotlink image. If I copy the URL to my address bar, I also get the hotlink image. So the hotlink prevention is working when the referer is blank or not one of your domains.

:cool: -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


Hi, i’m have same problem
my .htaccess does not prevent hotlink from the other domains
link to test:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^http://(www.)? [NC]

RewriteCond %{HTTP_REFERER} !^$
RewriteRule .(gif|jpg|jpeg|png|bmp|zip|rar|mp3|exe|ace)$ index.php [L]

RewriteEngine on

RewriteCond %{HTTP_HOST} ^

RewriteRule ^(.*)$$1 [R=permanent,L]

RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]


[quote]RewriteCond %{HTTP_REFERER} !^http://(www.)? [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .(gif|jpg|jpeg|png|bmp|zip|rar|mp3|exe|ace)$ index.php [L][/quote]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^
$ [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule .*.(gif|jpg|jpeg|png|bmp|zip|rar|mp3|exe|ace)$ [R,NC]

Maximum Cash Discount on any plan with MAXCASH


Was the change from “baixar” to “baixa” intentional?



its work!
very very thank you


“baixar” translated into English means "download"
My site is for Brazilians

But I correct to “baixar” the htacess of sxi


Argh typo… sorry about that!

Glad you got it sorted :wink:

Maximum Cash Discount on any plan with MAXCASH


i try

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www.)?$ [NC]
RewriteRule .
.(gif|jpg|jpeg|png|bmp|zip|rar|mp3|exe|ace)$ - [F]

but all my files .zip, .exe dont start downloading from my reffer website link