Forum Moderators: phranque

Message Too Old, No Replies

Forward users to new file locations

         

rickbass

1:08 pm on Jan 13, 2006 (gmt 0)

10+ Year Member



Hi all,

What I'm looking to do is the following. Any pointers on how to do this with .htaccess or a rewrite or even php would be greatly appreciated.

I'm about to move all the media files (which are crippling my server) onto a new one, but (for complex reasons) want to leave the site itself where it is.

I've therefore created a subdomain for the new files on the new server (e.g. [media.mysite.com)....]

Now, I want to be able to automatically redirect people who try to access an old file (e.g. [mysite.com...] to the same file on the new server (http://media.mysite.com/video.mov).

The files I'll be doing this for are wmv, rm, mov and mp3...

Does anyone know how this might be done (preferably without adding a reference to each individual file - there are many hundreds)?

Many thanks in advance.

jdMorgan

5:05 pm on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rickbass,

Welcome to WebmasterWorld!

mod_proxy and mod_alias are the first two modules I'd read up on for this kind of application. This would make the 'move' of the files entirely transparent to users. However, the *request-handling* for the files would still pass through your 'old' server to the new one with this approach. Most of the work would be done by the new server, but you may not even want the request-handling load on the front-end (I don't know, you'd have to test this and decide).

Otherwise, mod_alias and mod_rewrite both include directives that allow redirecting exampleA.com/<anything> to exampleB.com/<anything> using a single directive, and making the redirection as selective as you like -- based on requested directory, filetype, or both.

ref: Apache modules [httpd.apache.org]

Jim

rickbass

5:08 pm on Jan 13, 2006 (gmt 0)

10+ Year Member



Thanks Jim.

I dont mind the requests - its purely network capacity the larger files take up thats causing problems.

ill look into the modules you suggest.

jdMorgan

5:17 pm on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> network capacity

OK, then don't use the proxy solution -- it's only good for CPU and disk overload problems, and would have no beneficial effect -- and possibly a detrimental effect -- on the server's subnet.

A simple redirect may be the best solution -- assuming that you can update the old URLs to eliminate the need for the redirect over time. RedirectMatch in mod_alias is probably the 'best fit' for this task, assuming you don't need to place any non-URL-based conditions on the redirects.

Jim