Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Last active August 29, 2015 14:04
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 Greg-Boggs/a1f6702ed715021ff3b2 to your computer and use it in GitHub Desktop.
Save Greg-Boggs/a1f6702ed715021ff3b2 to your computer and use it in GitHub Desktop.
Serve remote files locally so you don't have to sync images from production for local development EDIT example.com
### Apache Rewrite
RewriteEngine on
# Force image styles that have local files that exist to be generated.
RewriteCond %{REQUEST_URI} ^/sites/([^\/]*)/files/styles/[^\/]*/public/((.*))$
RewriteCond %{DOCUMENT_ROOT}/sites/%1/files/%2 -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Otherwise, send anything else that's in the files directory to the
# production server.
RewriteCond %{REQUEST_URI} ^/sites/[^\/]*/files/.*$
RewriteCond %{REQUEST_URI} !^/sites/[^\/]*/files/css/.*$
RewriteCond %{REQUEST_URI} !^/sites/[^\/]*/files/js/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://www.example.com/$1 [QSA,L]
### Nginx Rewrite (only use if you don't run apache)
# Place inside server block Forward requests for images to another site
location ~ ^/sites/default/files/(.*)\.(jpg|gif|png)$ {
rewrite ^(.*)$ http://www.example.com$1 last;
}
/**
* Include a local settings file if it exists.
*/
$local_settings = dirname(__FILE__) . '/settings.local.php';
if (file_exists($local_settings)) {
include $local_settings;
}
// https://gist.github.com/brockboland/1633790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment