Skip to content

Instantly share code, notes, and snippets.

@chales
Last active December 15, 2015 19:39
Show Gist options
  • Save chales/5312358 to your computer and use it in GitHub Desktop.
Save chales/5312358 to your computer and use it in GitHub Desktop.
For local (Drupal) sites where you don't want to eat up drive space from file syncs, have apache pull them from the production sites instead. http://getlevelten.com/blog/mark-carver/dont-sync-drupal-files-local-environments-redirect-them-instead
<VirtualHost 0.0.0.0:80>
ServerName mysite.sandbox
DocumentRoot /path/to/mysite.sandbox
<IfModule mod_rewrite.c>
RewriteEngine on
# Request resides in your 'sites/default/files' folder.
RewriteCond %{REQUEST_URI} ^/sites/default/files/(.*)$
# File doesn't exist.
RewriteCond %{REQUEST_FILENAME} !-f
# Directory doesn't exist.
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect request to your development or production server.
RewriteRule ^/sites/default/files/(.*)$ http://dev.example.com/sites/default/files/$1 [L]
</IfModule>
<Directory /path/to/mysite.sandbox>
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment