Skip to content

Instantly share code, notes, and snippets.

@ngstigator
Last active October 9, 2018 22:18
Show Gist options
  • Save ngstigator/cd49dc62f9b7c1c0b61077f770c017c2 to your computer and use it in GitHub Desktop.
Save ngstigator/cd49dc62f9b7c1c0b61077f770c017c2 to your computer and use it in GitHub Desktop.
# Case sensitive
rewrite ^/[Nn][Ff][Pp]romo/?$ /now-fresh-offer/ redirect;
rewrite ^/(?i)GatherDog/?$ /for-dogs/gather/ permanent;
# URL params
location /some/path$ {
if ($query_string ~* "page=(.*)$") {
rewrite ^(.*)$ /destination? permanent;
}
}
# each $arg is identified e.g. ?lang=fr can be referenced by $arg_lang (in this case equals 'fr')
if ($args ~ "page_id=(.*)" ) {
rewrite /?(.*)?$ /? permanent;
}
# remove trailing /subpath/
rewrite ^/(.*)/subpath/?$ /$1 permanent;
## images from production
# Matches any URL containing /wp-content/uploads/
location ~ "^(.*)/content/uploads/(.*)$" {
try_files $uri @prod_serv;
}
# Will redirect requests to your production server
location @prod_serv {
rewrite "^(.*)/content/uploads/(.*)$" "http://example.com/content/uploads/$2" redirect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment