Forked from iansvo/nginx-redirect-uploads-to-production
Last active
August 9, 2023 04:51
-
-
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.
This file contains 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
# 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