|
|
#1 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Jun 2004
Hosted on Dedicated
12 posts
Gave thanks: 0
Thanked 0 times
|
I've been having problems with people leeching videos from my site and I also have a download script installed (it just masks the actual file location and counts how many times a file is downloaded). I have the script set up so my links to download the videos are like mysite.net/dl/download.php?file=id#
Is there a correct way to do this with .htaccess in my /dl/ folder so that anyone who calls /dl/download.php?file=id# from any other website is redirected to my index page? I tried a couple of different things that I saw on on tutorial sites but one caused an internal server error and the other redirected me to my index page no matter what.Thanks. |
|
|
|
|
|
#2 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,092 posts
Gave thanks: 48
Thanked 131 times
|
Not entirely sure about using .htaccess to do it, but you could modify your PHP script.
PHP Code:
|
|
|
|
|
|
#3 (permalink) |
|
L'Awesome Advocate
Super #1
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
|
That's an interesting way to block hotlinkers. Would that also include *.domain.tld or *.domain.tld/*?
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#4 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Nov 2004
Lives in San Francisco
364 posts
Gave thanks: 0
Thanked 3 times
|
This might work if put in .htaccess. I use a similar setup on one of my sites but am not sure if the .php?file= is gonna throw it off or not.
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://domain.tld/dl/download.php?file=.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.tld/dl/download.php?file=.*$ [NC]
RewriteRule .*\.(wmv|png|jpg|gif|mov|avi)$ http://domain.tld/ [R,NC]
|
|
|
|
|
|
#5 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,092 posts
Gave thanks: 48
Thanked 131 times
|
It's not to prevent people from hotlinking, it's to see where people are coming from. If the people aren't coming from the website, than it denies them access.
Just a thought.. I remember that some browsers have trouble with the referer thing, so it might be a good idea to add "OR != null" to the if statement. |
|
|
|
|
|
#6 (permalink) |
|
Surpass Fan
Super #1
Joined in Aug 2004
Hosted on SH58
1,688 posts
Gave thanks: 6
Thanked 7 times
|
and you should to a strpos() on the HTTP_REFERER, instead of doing an exact match. HTTP_REFERER logs filenames, too. So you should do something along the lines of:
PHP Code:
__________________
- Evan Charlton | [site] | Server - SH58 |
|
|
|
|
|
#7 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Nov 2004
Lives in San Francisco
364 posts
Gave thanks: 0
Thanked 3 times
|
Since Kicker didn't catch it yet and at the risk of a direct copy & paste, the code should read:
PHP Code:
|
|
|
|
|
|
#8 (permalink) |
|
L'Awesome Advocate
Super #1
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
|
How do you even see these things! I wouldn't have seen that unless you mentioned it lolz.
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|