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 local requests for images
location ~ "^/wp-content/uploads/(.*)$" {
try_files $uri @prod_uploads;
}
```
Using WP Local, this can go in the ./conf/nginx/site.conf.hbs file, inside the server block (I usually drop it in right before the “WordPress Rules” section).