Reputation: 2951
I would like to change only the first part of the url on a group of pages.
Eg.
domain.com/change/this/that/other
to
domain.com/changed/this/that/other
in the example everything after and including this would be dynamic
I thought this would work
location ~* ^/change/(.*)$ {rewrite ^ http://domain.com/changed/$1 permanent; break;}
but doesnt
Upvotes: 3
Views: 9218
Reputation: 316
Regex capture variables relate to rewrite block itself.
location ~* ^/change/(.*)$ {
rewrite ^/change/(.*)$ http://example.com/changed/$1 permanent;
break;
}
You can see the examples: http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
Upvotes: 11