Hi

Im setting up a news distribution system... sort of... i want to record everyone who downloads the news articles... so ive blocked direct linking to the pdf files using an htaccess file.

my htaccess file redirects people to a page which captures where they came from ( for interests sake) and then tells them they have tried to access a file without authorization... ie, without going through my website and being 'counted'...

so now I want to find the url they typed in to access that file directly, so that i can provide a link to it, this time through my website, and thus give them access but also be able to 'count' them and provide accurate analytics on viewership...

how do i find that url they originally typed in? I currently collect the referer_url but dont know if I can get the one they typed in...?!

Thanks lworks

lifeworks,

I'm not certain but think you have to compose your mod_rewrite rule such that it passes on the originally request url as a parameter in the querystring.

Original request
http://www.mydomain.example/mydoc.pdf

Redirect
http://www.mydomain.example/dochandler.php?doc=http://www.mydomain.example/mydoc.pdf

Then, in dochandler.php, you can pick up the original request as $_GET['doc'] .

All you have to do is get your mind round how to write the mod_rewrite directive, for which I wish you all the very best of luck though probably not so difficult if you are any good at POSIX regular expressions.

Airshow

aaah, good idea Airshow! Unfortunately I kno nothing about mod_rewrite directives... haha, but at least I have something to mvoe on now

Thanks

so i did some research into mod_rewrite... found a good article here http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/ - ended up following through on air shows advice and managed to pass the url through to my catch page

below is my htaccess directive, seems to be working, make sure you include your own domain in the whitelist... these directives bounce any hotlinks to pdf, doc or txt files

# Give Hotlinkers a 403 Forbidden warning.  
RewriteEngine on  
RewriteCond %{HTTP_REFERER} !^http://www.partnerdomain\.com/?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.ourdomain\.com/?.*$ [NC]  
RewriteRule \.(pdf|doc|txt)$ http://ourdomain.com/redirect.php?url=%{REQUEST_FILENAME} [R,NC]
commented: nice link! Thanks :) +5

Lifeworks,

Wow!! So the blind CAN lead the blind!!

Well done indeed.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.