Forum Moderators: phranque
this page then checks if they are users on my website, updates the download counter and redirects them to the file.
// update counter
query("UPDATE `files` SET `counter`=`counter`+1 WHERE `id`='$id'");
// redirect to file
header('location:http://www.example.co.uk/uploads/'.$filename); so people cant use up my bandwidth without me knowing, i want to stop people from downloading anything if the referer isnt this link.
i have tried:
RewriteCond %{HTTP_REFERER} files/[a-z]+/[0-9]+/download/$
RewriteRule uploads/.{1,}\..{3,4} - [L] RewriteCond %{HTTP_REFERER} ^.*/[a-z]+/[0-9]+/download/$
RewriteRule uploads/.{1,}\..{3,4} - [L] RewriteCond %{HTTP_REFERER} ^http://%{HTTP_HOST}/[a-z]+/[0-9]+/download/$
RewriteRule uploads/.{1,}\..{3,4} - [L] does anyone know what im doing wrong?
thanks for any help in advance
Will
[edited by: jdMorgan at 2:28 am (utc) on Mar. 17, 2006]
[edit reason] examplified. [/edit]
RewriteCond %{HTTP_REFERER} ^http://%{HTTP_HOST}/[a-z]+/[0-9]+/download/$
RewriteCond %{HTTP_REFERER} ^(http://[^/]+)
RewriteCond %{HTTP_HOST)<>%1 ^([^<]+)<>\1$ [NC]
RewriteRule ^uploads/[^.]+\..{3,4}$ - [L]
Therefore
if %{HTTP_HOST}<>%{HTTP_REFERER}(partial) == %{HTTP_HOST}<>%{HTTP_HOST}<>%,
then %{HTTP_REFERER}(partial) == %{HTTP_HOST}
This may need some tweaking to fit your actual referrers, since the match between hostname and the partial referrer substring saved in %1 must be exact. And as noted, it will only work on servers which support POSIX 1003.2 regular expressions (FreeBSD is one, and there are others.) I know of no way to support variable-to-variable compares in mod_rewrite without this POSIX 1003.2 trick.
Also, be aware that if you block blank referrers, visitors using "Internet security" software, those behind corporate or ISP caching proxies, and those who type in your URL directly will not be able to use your site.
Jim
Also, be aware that if you block blank referrers, visitors using "Internet security" software, those behind corporate or ISP caching proxies, and those who type in your URL directly will not be able to use your site.