Skip to content

Instantly share code, notes, and snippets.

@RiFi2k
Last active January 12, 2019 04:07
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 RiFi2k/2cda7016fc14d6a2eedd4f7c5eabbae8 to your computer and use it in GitHub Desktop.
Save RiFi2k/2cda7016fc14d6a2eedd4f7c5eabbae8 to your computer and use it in GitHub Desktop.
Nginx change img url on 404
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