Trouble with getting my .htaccess to work


#1

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://(. .)bluemoonsea.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(. .)dcj.bluemoonsea.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(. .)www.bluemoonsea.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(. .)www.dcj.bluemoonsea.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(gif|jpg|jpeg|png|bmp|mp3|mid|midi|html)$ http://i74.photobucket.com/albums/i246/dontcryjennifer/hotlink.gif [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 “bluemoonsea.com” directory, and the “dcj.bluemoonsea.com” directory. The main directory I want to focus on is my “dcj.bluemoonsea.com” 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: http://altlab.com/hotlinkchecker.php

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


#2

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 http://web-sniffer.net/ or your own script.

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


#3

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. =/


#4

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/


#5

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:

http://dcj.bluemoonsea.com/wallpapers/clocktower3_15_800x600.jpg

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: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#6

Hi, i’m have same problem
my .htaccess does not prevent hotlink from the other domains
link to test: http://www.baixar.info/files/1851/p2k_tool_5.3.zip

RewriteEngine on

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

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

RewriteEngine on

RewriteCond %{HTTP_HOST} ^baixar.info

RewriteRule ^(.*)$ http://www.baixar.info/$1 [R=permanent,L]

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


#7

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

Maximum Cash Discount on any plan with MAXCASH


#8

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

-Scott


#9

its work!
very very thank you


#10

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

But I correct to “baixar” the htacess of sxi


#11

Argh typo… sorry about that!

Glad you got it sorted :wink:

Maximum Cash Discount on any plan with MAXCASH


#12

i try

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www.)?baixar.info(/)?.$ [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

=[