Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemac/88058da2500fe0930592cf2b56b14df6 to your computer and use it in GitHub Desktop.
Save davemac/88058da2500fe0930592cf2b56b14df6 to your computer and use it in GitHub Desktop.
Open the Nginx configuration for your site and look for a server block that listens for port 443. Look for something like Listen 127.0.0.1:443 ssl in the server { ... } block to find the right one. Add the following location rules near the top of the block, after any other definitions.
# Redirect requests to /wp-content/uploads/* to production
set $production themotoringnetwork.com.au;
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;
}
# End Redirect requests to /wp-content/uploads/* to production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment