Skip to content

Instantly share code, notes, and snippets.

@blizzrdof77
Last active November 29, 2017 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blizzrdof77/388ec4ddee8127f424042184afdac9d6 to your computer and use it in GitHub Desktop.
Save blizzrdof77/388ec4ddee8127f424042184afdac9d6 to your computer and use it in GitHub Desktop.
Load TurdPress uploads from stage/production when files don't exist locally (complex version w/ multiple environments/fallbacks)
# LOAD UPLOADS FROM STAGE/PRODUCTION
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite local to stage
RewriteCond %{HTTP_HOST} ^example\.dev$
RewriteRule ^wp-content/uploads/(.*)$ http://example.stage.com/wp-content/uploads/$1 [L]
RewriteCond %{HTTP_HOST} ^example\.dev$
RewriteRule ^wp-content/uploads/(.*)$ http://example.stage.com/wp-content/uploads/$1 [L]
# Rewrite stage to secondary stage
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^example\.stage\.com$
RewriteRule ^wp-content/uploads/(.*)$ http://example.stage.com/wp-content/uploads/$1 [L]
# Rewrite secondary stage to production
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^example\.stage\.com$
RewriteRule ^wp-content/uploads/(.*)$ http://www.example.com/wp-content/uploads/$1 [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment