Skip to content

Instantly share code, notes, and snippets.

@vangog
Created April 6, 2014 15:47
Show Gist options
  • Save vangog/10007832 to your computer and use it in GitHub Desktop.
Save vangog/10007832 to your computer and use it in GitHub Desktop.
### Apache Rewrite
# 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] 
### nginx Rewrite
## Try local files first, otherwise redirect to a development server.
location ^~ /sites/default/files {
try_files $uri @dev_redirect;
}
## Development Server Redirect
location @dev_redirect {
rewrite ^ http://dev.example.com$request_uri? permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment