Created
August 7, 2023 16:40
-
-
Save iansvo/5977caf12d1df19e96ca67f550cb3afa 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
set $production your-prod-server.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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment