Web Hosting Talk







View Full Version : One link for downloading a file on multiple servers


Hercule
05-09-2005, 03:12 AM
It's for distributing a shareware game.

I want a a link like http://www.mainwebsite.com/Shareware.zip which dynamically send the download to http://www.secondwebsite.com/dsdsf/Shareware.zip
or
http://www.cheapwebsite.com/Shareware.zip
or
...


The user still see http://www.mainwebsite.com/Shareware.zip , but he download on other servers.

thanks in advances.

Xenatino
05-09-2005, 04:56 AM
Use .htaccess to redirect Shareware.zip to a PHP file which randomly selects one of your servers and starts the download.

RangerOfFire
05-09-2005, 07:07 AM
Why not just use a php file to start with like everyone else?

t3r0
05-09-2005, 07:48 AM
Hi,

you cant do that with php if you want users to see only the www.mainwebsite.com address....

one really simple loadbalancing solution using mod_rewrite....


add to httpd.conf or .htaccess


RewriteEngine on
RewriteMap server rnd:/path/to/servers.txt
RewriteRule ^/download/(.+)$ http://${server:server}/download/$1 [P,L]


and servers.txt

server location1.com|location2.com|location3.com


Not tested but should be ok...


So what this does is redirect requests to download directory in mainsite to random servers download directory

CAUTION: DO NOT do not add the mainsite.com to servers.txt, it will cause an endless loop...


Hope this atleast points you to right direction :)


- Tero

Hercule
05-11-2005, 06:07 AM
thanks I will try that.

error404
05-11-2005, 06:22 AM
That mod_rewrite solution will just proxy the download file, which I don't think is what you want -- all requests will still pass all data through your server. I would use mod_rewrite combined with a PHP script to select a random URL and use the Location header to redirect the browser to it.