Skip to content

Instantly share code, notes, and snippets.

@solepixel
Last active February 13, 2024 15:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save solepixel/254ccb9919967846fa85 to your computer and use it in GitHub Desktop.
Save solepixel/254ccb9919967846fa85 to your computer and use it in GitHub Desktop.
This htaccess snippet (lines 4-12) will pull any missing images from another URL. Helpful when developing locally or on a staging site where media is present on production but is too much to migrate to staging or locally.
<IfModule mod_rewrite.c>
RewriteEngine On
# BEGIN Use uploads directory from Live Site
RewriteBase /wp-content/uploads/
RewriteCond %{HTTP_HOST} !^www\.livedomain\.com
RewriteCond %{HTTP_HOST} !^livedomain\.com
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) https://livedomain.com/$1 [L,NC]
# END Media from Live Site
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment