views:

822

answers:

1

Server A - application

Server B - static media from uploads, no app

App on Server A processes the upload, validates and posts a job to convert it, after the conversion it's moved to Server B via copy (mounted drive) . Then the media file is loaded via a player on the page on Server A.

I want to load the file via the remote url http://serverB/files/file1234.wtf and if the file is still not there yet (not yet copied), to transparently redirect it to http://serverA/tmp_files/file1234.wtf

How to do it with htaccess or any other way?

+1  A: 

Assuming Apache + mod_rewrite, this should work in your .htaccess on serverB:

RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/files/%{SCRIPT_FILENAME} !-f
RewriteRule ^/files/(.*)$ http://serverA/tmp_files/$1 [L,R=temporary]
Steve Madsen