Apache Server configuration support - mod_rewrite syntax query

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > May 2006 > mod_rewrite syntax query





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author mod_rewrite syntax query
Mickey

2006-05-18, 1:17 pm

Hi,

I am trying to prevent the hotlinking of mp3, image files etc.
Basically, what I am trying to achieve is, if the user comes from
http://sub.domain.net then they can download the file, otherwise they
get the hotlink image.

I am currently using:

[CODE]
Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_HOST} !^sub\.domain\.net[NC]
RewriteRule .*\. (zip|mp3|avi|wmv|mpg|mpeg|flac|rar|shn|t
xt)$
http://sub.domain.hotlink.jpg [R,NC,L]

[/CODE]

But this is just downloading the "http://sub.domain.hotlink.jpg"
image.
I have been searching for hours but I still can't find a way to get
this right.

Any idea's what I'm doing wrong there?

Thanks in advance.

Robert Ionescu

2006-05-18, 7:16 pm

You missed to exclude the referer of that allowed domain.

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_REFERER} !=""
RewriteCond %{HTTP_REFERER} !^http://sub\.domain\.net[NC]
RewriteRule \. (zip|mp3|avi|wmv|mpg|mpeg|flac|rar|shn|t
xt)$
http://sub.domain/hotlink.jpg [R,NC,L]

--
Robert
Mickey

2006-05-18, 7:16 pm

Thanks for the reply.
I tried that earlier, but with that, I had the problem, that any
'REFERER' could download a file.
I am continuing to search old messages and google etc, but still, I am
unable to get anything to work. I'm not sure what I'm doing wrong
because the above seems to work for others.

Thanks again for the help.

Robert Ionescu

2006-05-21, 1:15 pm

Mickey wrote:
> I tried that earlier, but with that, I had the problem, that any
> 'REFERER' could download a file.


Do you have access to the httpd.conf? if yes, you could setup a
RewriteLog with

Rewritelog logs/rewrite.log
Rewriteloglevel 5

Also, which referer can you find in your access.log for that request?

--
Robert
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com