Forum Moderators: phranque

Message Too Old, No Replies

404 redirect to alternative server

Redirect to a mirror server that has the file

         

idonteven

10:25 pm on Feb 20, 2010 (gmt 0)

10+ Year Member



Hey, I've got one server that has a small HDD, and stores only some files, and I have a server with a bigger HDD that stores all files, including those that the small server has. The problem is that the small server indexes ALL files, and if someone tries to download a file that doesnt exist on the small server it will report 404, but INSTEAD i want it to redirect to the bigger server and get the file from there, example:
<attempt to get the file from the small server>
http://example.com/download/song1.mp3
<the small server will not find the file, and should try to redirect to the bigger server>
http://example.com:2975/download/song1.mp3

I played around with the Redirect command and couldn't solve it because most of these files are in the same folder, and I'd prefer the files to be fetched from the small server (since the bigger server isn't online 24/7)...

any suggestions? btw, is it possible to limit these rules to specific IPs / redirect to different file paths on that other server?

if my question isn't clear enough let me know...

jdMorgan

12:05 am on Feb 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is just the wrong approach. It is complex, cannot be as reliable (because it has two points of failure; two servers being half as reliable as one), and it is slow, because any client (browser) that gets redirected will have to issue a total of two requests for the files not on the 'small server', which slows them down.

I'd suggest you buy a bigger hard drive for the 'small server' or simply swap the servers. You're trying to fix a flat tire by re-designing the whole suspension system.

If you still want to dig into this, see Apache mod_rewrite, and note the "file-exists" function of the RewriteCond directive. That should get you started. But again, too complicated, unreliable, wrong approach.

Jim

idonteven

1:53 am on Feb 21, 2010 (gmt 0)

10+ Year Member



Ok, thanks a lot for suggestions. Since you're advising me not to go that way, I'll just rewrite the download client that my users use and make it handle this by itself.

(I'm avoiding redirection, the client will get help by the small server to decide where to get the file from...)

Thanks!