Skip to content

Instantly share code, notes, and snippets.

@dtateii
Created July 30, 2015 21:03
Show Gist options
  • Save dtateii/70173b998fde3d437d57 to your computer and use it in GitHub Desktop.
Save dtateii/70173b998fde3d437d57 to your computer and use it in GitHub Desktop.
Local Dev: Forward User-Generated Image Requests to Server
# APACHE RULE: DRUPAL (inside .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule sites/default/files/(.*) \
http://{site.com}/sites/default/files/$1 [NC,L]
</IfModule>
# APACHE RULE: WORDPRESS (inside .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule wp-content/uploads/(.*) \
http://{site.com}/wp-content/uploads/$1 [NC,L]
</IfModule>
# NGINX RULE: DRUPAL (inside server block)
location ~ ^/sites/default/files/(.*)\.(jpg|gif|png)$ {
rewrite ^(.*)$ http://{site.com}$1 last;
}
# NGINX RULE: WORDPRESS (inside server block)
location ~ ^/wp-content/uploads/(.*)\.(jpg|gif|png)$ {
rewrite ^(.*)$ http://{site.com}$1 last;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment