Put this within server { ... }
block of your vhost
location ~ "^(.*)/wp-content/uploads/(.*)$" {
if (!-e $request_filename) {
return 302 http://yourlivesite.com$request_uri;
}
}
Place it under wp-content/uploads/
directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://yourlivesite.com/wp-content/uploads/$1 [P,L] # use R=302 if P does not work
</IfModule>
NOTE: If the files are not being fetched from remote server, replace P
flag with R=302
, resulting it into [R=302,L]
in your .htaccess
file