Last active
March 11, 2016 11:44
-
-
Save markhalliwell/5249012 to your computer and use it in GitHub Desktop.
Redirect local sand-boxed Drupal file requests to a development server. This helps avoid having to sync (sometimes, very huge) file structures onto your local machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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