You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Techman <te...@netscan.ca> on 2007/12/23 02:18:20 UTC

[users@httpd] .htaccess and hotlinking question/problem

I have read about a hundred pages on hotlinking today and I have been trying
to implement an .htaccess file to prevent it, but so far nothing is working.

I am using Slackware Linux 10 and Apache 1.3.36.

What I want to do is stop people from directly downloading from my DL
directory.

i.e. www.mysite.com/download/myfile.avi

If they type in the above I want an error page displayed.

Currently I have an .htaccess file in the root directory of my site, as
follows.


RewriteEngine on
RewriteOptions inherit

RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER} !^http://www.mysite.ca/.*$ [NC]
RewriteRule .*.(avi|AVI|mpg|MPG|wmv|WMV|swf|SWF)$ - [F]

This is very simplistic, but I just want to get it working, then I can add
other options or whatever.

Any help on what I am doing wrong is appreciated, or any other solutions to
stop direct downloading.

Thanks



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] .htaccess and hotlinking question/problem

Posted by Joshua Slive <jo...@slive.ca>.
On Dec 24, 2007 2:30 AM, Techman <te...@netscan.ca> wrote:
> >From what I can figure out now, mod-rewrite is not installed. Now when I
> type in www.mysite.com/download/myfile.avi in my browser I get a server
> error.  There is nothing in my httpd.conf about mod_rewrite, nor can I find
> any files pertaining to it. This serves my purpose as it does stop the
> direct downloading of files, it's just not pretty and would be nice if it
> worked properly. Just so you know where I am coming from, I did not even
> know what mod_rewite was until a few days ago. If there is another way to
> test to see if it is installed, please let me know. I am not a guru on this
> stuff, just know enough to get by.

apachectl -M
will tell you all the modules you have loaded (if you are using the
most recent version of apache; otherwise, you'll need "httpd -l" and
check all the LoadModule directives in httpd.conf).

But you don't need mod_rewrite for this. Assuming you have control of
httpd.conf, you can use something like
http://httpd.apache.org/docs/2.2/env.html#examples
or
http://wiki.apache.org/httpd/DisableImageHotLinking

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] .htaccess and hotlinking question/problem

Posted by Techman <te...@netscan.ca>.
>>From what I can figure out now, mod-rewrite is not installed. Now when I
type in www.mysite.com/download/myfile.avi in my browser I get a server
error.  There is nothing in my httpd.conf about mod_rewrite, nor can I find
any files pertaining to it. This serves my purpose as it does stop the
direct downloading of files, it's just not pretty and would be nice if it
worked properly. Just so you know where I am coming from, I did not even
know what mod_rewite was until a few days ago. If there is another way to
test to see if it is installed, please let me know. I am not a guru on this
stuff, just know enough to get by. 

Thanks

> -----Original Message-----
> From: jslive@gmail.com [mailto:jslive@gmail.com] On Behalf Of 
> Joshua Slive
> Sent: December 22, 2007 10:30 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] .htaccess and hotlinking question/problem
> 
> On Dec 22, 2007 8:18 PM, Techman <te...@netscan.ca> wrote:
> >
> > I have read about a hundred pages on hotlinking today and I 
> have been 
> > trying to implement an .htaccess file to prevent it, but so 
> far nothing is working.
> >
> > I am using Slackware Linux 10 and Apache 1.3.36.
> >
> > What I want to do is stop people from directly downloading 
> from my DL 
> > directory.
> >
> > i.e. www.mysite.com/download/myfile.avi
> >
> > If they type in the above I want an error page displayed.
> >
> > Currently I have an .htaccess file in the root directory of 
> my site, 
> > as follows.
> >
> >
> > RewriteEngine on
> > RewriteOptions inherit
> >
> > RewriteCond %{HTTP_REFERER}!^$
> > RewriteCond %{HTTP_REFERER} !^http://www.mysite.ca/.*$ [NC] 
> > RewriteRule .*.(avi|AVI|mpg|MPG|wmv|WMV|swf|SWF)$ - [F]
> >
> > This is very simplistic, but I just want to get it working, 
> then I can 
> > add other options or whatever.
> >
> > Any help on what I am doing wrong is appreciated, or any other 
> > solutions to stop direct downloading.
> 
> And what exactly is happening when you try that? What exactly 
> do you type in your browser and what do you see in your 
> browser, you access_log and your error_log. Finally, and most 
> importantly, have you used the RewriteLog in httpd.conf to 
> see what mod_rewrite is seeing.
> In general, mod_rewrite is easier to deal with in httpd.conf 
> as well, if you can avoid using .htaccess.
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> 



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] .htaccess and hotlinking question/problem

Posted by Joshua Slive <jo...@slive.ca>.
On Dec 22, 2007 8:18 PM, Techman <te...@netscan.ca> wrote:
>
> I have read about a hundred pages on hotlinking today and I have been trying
> to implement an .htaccess file to prevent it, but so far nothing is working.
>
> I am using Slackware Linux 10 and Apache 1.3.36.
>
> What I want to do is stop people from directly downloading from my DL
> directory.
>
> i.e. www.mysite.com/download/myfile.avi
>
> If they type in the above I want an error page displayed.
>
> Currently I have an .htaccess file in the root directory of my site, as
> follows.
>
>
> RewriteEngine on
> RewriteOptions inherit
>
> RewriteCond %{HTTP_REFERER}!^$
> RewriteCond %{HTTP_REFERER} !^http://www.mysite.ca/.*$ [NC]
> RewriteRule .*.(avi|AVI|mpg|MPG|wmv|WMV|swf|SWF)$ - [F]
>
> This is very simplistic, but I just want to get it working, then I can add
> other options or whatever.
>
> Any help on what I am doing wrong is appreciated, or any other solutions to
> stop direct downloading.

And what exactly is happening when you try that? What exactly do you
type in your browser and what do you see in your browser, you
access_log and your error_log. Finally, and most importantly, have you
used the RewriteLog in httpd.conf to see what mod_rewrite is seeing.
In general, mod_rewrite is easier to deal with in httpd.conf as well,
if you can avoid using .htaccess.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org