Skip to content

Instantly share code, notes, and snippets.

@bigandy
Created February 23, 2018 11:27
Show Gist options
  • Save bigandy/ccf23c9ef619f39fd8037d30f3c53938 to your computer and use it in GitHub Desktop.
Save bigandy/ccf23c9ef619f39fd8037d30f3c53938 to your computer and use it in GitHub Desktop.
nginx redirect rule
// nginx redirect rule
if ($request_uri ~* \.(js|css|png|jpg|jpeg|gif|svg)) {
rewrite ^/(.+)\.(?:[a-z0-9]+)\.(js|css|png|jpg|jpeg|gif|svg) https://$host/$1.$2 permanent;
}
@bigandy
Copy link
Author

bigandy commented Feb 23, 2018

How to target only wp-content/themes/venture-harbour directory?

@bigandy
Copy link
Author

bigandy commented Feb 25, 2018

as in :

location ~* ^(.*/(wp-content)/themes/(venture-harbour)/)(.+).[0-9a-z]+.(js|css|png|jpg|jpeg|gif|svg)$ {
try_files $uri $1$2.$3;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment