Welcome to WebmasterWorld Guest from 50.19.156.133

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Using .htaccess to prevent file leeching

help

     

Et3rnal

11:46 am on May 20, 2003 (gmt 0)

10+ Year Member



I have been having trouble with sites leeching the files from my page. My files are mainly exe, zip, and rar files. All the posts I see about .htaccess has to do with images. Is there a way to prevent direct linking to my files? I copied a .htaccess from one of the posts and changed it around and it didn't work. This is what I used:

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.net [NC]
RewriteRule .*\.(exe¦zip¦rar)$ - [F]

I uploaded it to my downloads folder. I am such a noob to this, so any help would be appreciated.

Et3rnal

[edited by: DaveAtIFG at 3:53 pm (utc) on May 20, 2003]
[edit reason] Domain name revised [/edit]

jdMorgan

3:26 pm on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Et3rnal,

Your code is basically correct. Make sure you have spaces in front of the exclamation point "!" characters as shown and that you are using a solid pipe character instead of a broken pipe like this "¦" one - Posting code on the forum causes both of these problems. Note that ".*" at the begining of an unanchored pattern is not needed.

Also, try adding the Options directive as shown.
[code]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.net [NC]
RewriteRule \.(exe¦zip¦rar)$ - [F]
[code]
You might want to check your raw error log file after testing this rewrite - sometimes it will give you a very good hint if there is a problem.

If this doesn't work, you may not have access to mod_rewrite, or have the required priveleges to run it. Contact your hosting service and ask them.

HTH,
Jim

Et3rnal

4:48 pm on May 20, 2003 (gmt 0)

10+ Year Member



Well, I copied the code that you had in the last post. I uploaded it to my download directory and I don't get any errors this time but I still can download from other site. Would not having access to the mod_rewrite be the problem?

Thanks for your response

Et3rnal

lorax

5:05 pm on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Could be - check with your host about what they allow or don't allow.

jdMorgan

6:31 pm on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Et3rnal,

Also, make sure you are clearing your browser cache (Temporary Internet Files) between tests! That's the number one problem most folks have when testing. If you already have a copy of the requested file in your cache, the request never gets to your server, so it can't be blocked.

HTH,
Jim

Et3rnal

6:51 pm on May 20, 2003 (gmt 0)

10+ Year Member



Well I cleared the cache, and contacted my host. My host said that Frontpage extensions were on and needed to be disabled. Which they are disabled now, but my download .htaccess file in my download directory still doesn't prevent leeching. Should I change the .htaccess file in my public_html directory. This the email:

"FP ext. disbaled.

Delete exisitng .htaccess file and create your own in /var/www/html"

So my .htaccess in that directory is any good now?

Told you Iam a total noob, but thx for the replies.

Et3rnal

jdMorgan

7:18 pm on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Et3rnal,

Your code should work either in your downloads directory or in your root (home page) directory.

Clear the cache before every test to get consistent results.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month