Last active
January 12, 2019 04:07
-
-
Save RiFi2k/2cda7016fc14d6a2eedd4f7c5eabbae8 to your computer and use it in GitHub Desktop.
Nginx change img url on 404
This file contains hidden or 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
location ~* (/[^/]+/)?uploads/(.+\.(png|gif|jpe?g)) { | |
try_files $uri $uri/ /index.php?q=$uri&$args; | |
expires max; | |
log_not_found off; | |
access_log off; | |
} | |
location ~ ^(.*)\/wp-content\/uploads\/(.*)$ { | |
try_files $uri @missing; | |
} | |
location @missing { | |
rewrite "^(.*)/wp-content/uploads/(.*)$" "http://production-url.com$1/wp-content/uploads/$2" redirect; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment