Loading media on local WordPress using remote database

Somewhere in the core, URLs get absolutely pathed when put into the database.

Why don’t you just load all your images from your staging server? Have the staging server hold the files while your local mirrors it. Add the following to your .htaccess to your local uploads folder and the contents are as follows:

# Attempt to load files from production if they're not in our local version
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  # Replace http://example.com with your production site's domain name
  RewriteRule (.*) http://example.com/wp-content/uploads/$1
</IfModule>

Leave a Comment