Skip to content

Instantly share code, notes, and snippets.

@morganestes
Created May 28, 2020 02:47
Show Gist options
  • Select an option

  • Save morganestes/4048967703b8c78866181659805a1c9e to your computer and use it in GitHub Desktop.

Select an option

Save morganestes/4048967703b8c78866181659805a1c9e to your computer and use it in GitHub Desktop.
WordPress image proxy for development
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule wp-content/uploads/(.*) https://example.com/wp-content/uploads/$1 [NC,L]
</IfModule>
set $production example.com;
# Redirect requests to /wp-content/uploads/* to production server
location @prod_uploads {
rewrite "^(.*)/wp-content/uploads/(.*)$" "https://$production/wp-content/uploads/$2" break;
}
# Rule for handling requests to https://example.com/wp-content/uploads/
location ~ "^/wp-content/uploads/(.*)$" {
try_files $uri @prod_uploads;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment