Skip to content

Instantly share code, notes, and snippets.

@allybee
Last active December 19, 2015 14:39
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 allybee/29fb76fd0e40b29937ea to your computer and use it in GitHub Desktop.
Save allybee/29fb76fd0e40b29937ea to your computer and use it in GitHub Desktop.
Placed in wherever your media is uploaded, this will check your local media directory for a requested file and, if it doesn’t exist, attempt to load it from production. This makes it easier to work on a local copy of a production site since you won’t need your own copy of the media directory.
# concrete5
# files/.htaccess
# NOTE: This doesn't work for images that are created with concrete5's getThumbnail()
# Attempt to load files from production if they're not in our local version
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Replace http://domain.com with your production site's domain name
RewriteRule (.*)$ http://domain.com/files/$1 [R,L,NC]
</IfModule>
# Wordpress
# wp-content/uploads/.htaccess
# Attempt to load files from production if they're not in our local version
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Replace http://domain.com with your production site's domain name
RewriteRule (.*) http://domain.com/wp-content/uploads/$1
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment