0

I have a multisite WordPress install with a large uploads folder. I want to setup multiple staging areas both on the local and remote server. But this way, it will take quite a lot of disk space. So I wonder if I can use the uploads folder from the live site for all these staging areas, e.g., load all images from mysite.com on mysite.dev and test.mysite.com and load images from the corresponding network site for other network sites.

I found a plugin called Uploads by Proxy but it does not work with multisite installs. Is there any plugin solution to achieve this? I thought also of replacing image URLs in the database but this is going to be a regex replacement and this is going to take too long each time I update the database.

3
  • There are database migration plugins available that will change all the URLs quite easily. Some have specific setups for staging-to-production mirroring. Personally I prefer to have a full copy of production on staging - that is, I copy the uploads folder and all - if your space is that limited, it might be worth looking into some other web hosts or buying an external hard drive with enough storage to handle it all if it's a local issue. Finally, you may want to look into a different web host that has staging options on the production server itself. This is my preference.
    – WebElaine
    Sep 20, 2017 at 14:07
  • I am sure there are such plugins but can you please give an example of a plugin that allows replacing urls for images only and does it faster than the search-replace command of wp cli? The site is on SiteGround cloud hosting and there is a limit on drive storage increase. They have staging area option but it does not support multisites and loading images from the main site is exactly what their staging areas do. Sep 21, 2017 at 14:35
  • Sorry, plugin recommendations are off-topic here. You might ask SG support as they may have other customers in the same boat and know what those other site owners are doing as workarounds.
    – WebElaine
    Sep 21, 2017 at 14:38

1 Answer 1

0

I found a solution on Stack Overflow.

So I added the following to .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/uploads/(.*) http://their-domain.com.com/wp-content/uploads/$1 [R=301,NC,L]

This replaces all references to the local uploads folder with a remote uploads folder on the fly and I see images on my local dev area without having to download 30GB+ uploads folder. On the other hand, I cannot remove or replace an image on my staging area.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.