Forum Moderators: phranque
But he's away, and we've got a deluge of people hotlinking the above-mentioned pretty pictures.
I can do this part:-
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif¦jpg)$ [mydomain.com...] [R,L]
But in looking at the "offenders" sites, they're also hotlinking all our downloads, on our bandwidth! Cheeky devils.
Is there anything I can add to that code to point the user to our parent download page, rather than the actual file?
All downloads are .zip without exception. So I guess I need something like the above that points a .zip to a .php page if it hasn't come from our own domain.
eg:-
They click on www.mydomain.com/downloads/widgets.zip which is hotlinked from someone elses website
and instead they get:-
www.mydomain.com/downloads/index.php
I really don't know what I'm doing here, so if you can make it simple, I'd be really grateful!
Would it be as simple as:-
RewriteRule \.(zip)$ [mydomain.com...] [R,L]
?
Thanks,
TJ
Instead of your first ruleset, I'd suggest:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.[b]com [NC][/b]
RewriteRule \.(gif¦jpg)$ [b]/dont[/b]_hot_link_please.gif [b][L][/b]
For maximum compatibility, I'd suggest you create a jpg version of dont_hot_link_please.gif, and then use this rule:
RewriteRule \.(gif¦jpg)$ /dont_hot_link_please.$1 [L]
---
Question 2... Bad news: No, you cannot redirect from a zip file to an html or php page - The browser may not know how to handle the sudden and unexpected MIME-type change. Instead, simply return a 403-Forbidden response:
RewriteRule \.zip$ - [F]
You could also create a zero-length zip file, and rewrite hotlink requests to serve that file in a manner similar to the image file rewrite, but I believe strongly in keeping things simple (and robust).
Jim