.htaccess file redirection if doesn't exist, remote file upload

Server A - application

Server B - static media from downloads, no app

The application on server A processes the download, validates, and submits a job to convert it after conversion, which it has moved to server B using a copy (mounted disk). The media file is then loaded through the player on the page on server A.

I want to upload a file via remote url http: //serverB/files/file1234.wtf and if the file still doesn't exist (not copied yet) to transparently redirect it to http: //serverA/tmp_files/file1234.wtf

How can I do this using htaccess or any other way?

+1


a source to share


1 answer


Assuming Apache + mod_rewrite, this should work in yours .htaccess

on ServerB:



RewriteEngine on

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

      

+2


a source







All Articles