Get WordPress images from a different site

Developers usually work on their local installs before pushing any changes to the live or production server and that’s how a developer’s workflow should be.

In order to setup a local or dev install on which a developer can work or test, they need to pull down the codebase and database dump to exactly mirror the site but they also need to download the media folder to make sure all images show up fine, which can have a bit of its own issues.

Codebase is usually under version control, so that’s easy to pull and push changes. Database dump is a single file to download. But media folder can be very large sometimes and not possible to download every time you want to sync up with the files on live site. A super easy solution, that I use, is to setup a redirection rule in your local webserver to redirect all media requests to the live site and then you don’t need to sync your media files at all.

Here is a single line, that can be added in your WordPress .htaccess file (if you are using apache, for nginx or any other webserver, idea stays the same, syntax will vary ofcourse):

`
RedirectMatch 302 ^/wp-content/uploads/(.*)$ http://mylivesite.com/wp-content/uploads/$1
`

Voila! Now you have all images showing up from live site directly ๐Ÿ™‚

P.S. – This doesn’t work if you are offline for obvious reasons.


Comments

One response to “Get WordPress images from a different site”

  1. That’s helpful, esp. when one got 29+ GBs of images.

    Thanks ๐Ÿ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *