Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I own a website which contain a lot of freeware stuff to download on it. The problem I'm facing is that people from around the world are taking the direct links of the files (for example .zip files) and posting them on their websites and general forums. I am getting a huge amount of bandwidth and that's ok, but the number of pages visited is low. Is there a way or a script that I can add to the links, so that when someone presses on the link from a foreign website, a page from my website opens instead, which then lets him download the file so I can get more visits.

For example, this is a address from my website:

http://sy-stu.org/stu/PublicFiles/StdLibrary/Exam.zip

When anyone presses on it, it will start the downloading process directly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
303 views
Welcome To Ask or Share your Answers For Others

1 Answer

Your site is hosted by an Apache web server, so you should be able to do the following in your site's httpd.conf (or virtual host block)

RewriteEngine On
RewriteCond   %{HTTP_REFERER} !^$
RewriteCond   %{HTTP_REFERER} !^http://(www.)?yourdomain.com/  [NC]
RewriteRule   ^/PublicFiles/  /page-about-direct-links.html

That is basically saying:

  1. Turn the mod_rewrite engine on
  2. If the HTTP Referrer is not blank…
  3. And doesn't contain my domain name (with or without “www.”)…
  4. Redirect any requests for anything under /PublicFiles/ to /page-about-direct-links.html

More information on mod_rewrite can be found here: mod_rewrite - Apache HTTP Server


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...