Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2003, 02:38 AM   PM User | #1
kornhead
New to the CF scene

 
Join Date: Jan 2003
Location: Spokane WA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kornhead is an unknown quantity at this point
I need help with htaccess

Ever since I put videos and mp3s on my site lots of other sites have linked them which in turn uses up my bandwidth. I was told by my host that I could block access from certain ips or urls by adding

order allow,deny
deny from www.korni.by.ru
deny from www.geocities.com/kornheavymetalenglish
allow from all

to my .htaccess file. When I did that I went to the sites that should have been blocked from my site and I was still able to download my videos and mp3s that they had linked off of my site. Please help me I can't afford to have these people using up all my bandwidth.
kornhead is offline   Reply With Quote
Old 01-12-2003, 03:06 AM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
http://www.javascriptkit.com/howto/htaccess10.shtml

?
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 01-12-2003, 03:47 AM   PM User | #3
kornhead
New to the CF scene

 
Join Date: Jan 2003
Location: Spokane WA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kornhead is an unknown quantity at this point
I also tried putting the below in my .htaccess but that also did not work.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.kornhead.net/.*$ [NC]
RewriteRule \.(mp3|jpg)$ - [F]
kornhead is offline   Reply With Quote
Old 01-12-2003, 04:04 AM   PM User | #4
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Re: I need help with htaccess

Ok, I'm no .htaccess expert, but shouldn't something like:

order deny,allow
allow from www.kornhead.ne
deny from all

work?
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 01-12-2003, 04:43 AM   PM User | #5
kornhead
New to the CF scene

 
Join Date: Jan 2003
Location: Spokane WA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kornhead is an unknown quantity at this point
Didn't work. It blocked everyone.
kornhead is offline   Reply With Quote
Old 01-12-2003, 07:42 AM   PM User | #6
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Dont waste your time doing it with htacess. In order to protect the files you have to use HTTP_REFERRER however that information is given to the server from the users browser. Not all browsers give that information or give it correctly or allow people to change it.

Put the files in a non-web accessible directory and store the paths in a database then in the pages the links for the files will run through the database which you can then control and people can't hotlink.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 01-19-2003, 09:01 PM   PM User | #7
orchidred
New to the CF scene

 
Join Date: Jan 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
orchidred is an unknown quantity at this point
I have been having a similar problem with my .htaccess file. I also want to disable hotlinking, for which I used the following code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

When I use this though (which I believe is written correctly) my server then blocks my own domain as well. Hence, none of the images on my site work if I try and disable hotlinking. I contacted the support people at my server, and they just told me that their system randomly rewrites htaccess files. Is that normal?

I would like to know more about protecting files by putting them in a non-web accessible folder, as states below:

"Put the files in a non-web accessible directory and store the paths in a database then in the pages the links for the files will run through the database which you can then control and people can't hotlink."

Im guessing this is some form of PHP script? Or? If someone could post a tutorial link for how to accomplish this that would be great. The tutorial would have to be rather detailed though since I have no idea how to write PHP.

Any help is appreciated. Much as I ask people not to direct link to media on my site, everyone does!
orchidred is offline   Reply With Quote
Old 01-28-2003, 08:59 PM   PM User | #8
pb&j
Regular Coder

 
Join Date: Jun 2002
Location: Canada
Posts: 254
Thanks: 0
Thanked 0 Times in 0 Posts
pb&j is an unknown quantity at this point
Re: I need help with htaccess

Quote:
Originally posted by kornhead

order allow,deny
deny from www.korni.by.ru
deny from www.geocities.com/kornheavymetalenglish
allow from all
Try taking off the www part (leaving the first period though).

order allow,deny
deny from .korni.by.ru
deny from .geocities.com/kornheavymetalenglish
allow from all
pb&j is offline   Reply With Quote
Old 01-30-2003, 12:28 AM   PM User | #9
pb&j
Regular Coder

 
Join Date: Jun 2002
Location: Canada
Posts: 254
Thanks: 0
Thanked 0 Times in 0 Posts
pb&j is an unknown quantity at this point
Quote:
Originally posted by kornhead
I also tried putting the below in my .htaccess but that also did not work.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.kornhead.net/.*$ [NC]
RewriteRule \.(mp3|jpg)$ - [F]
You have to find out from your web host if they support mod_rewrite. Some hosts do not and thus this attempt would fail.
pb&j is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:54 PM.


Advertisement
Log in to turn off these ads.