Reputation: 1236
I need
/secure/token/timestamp/path/to/the/resource/
to be rewritten in this format:
/s/path/to/the/resource/?st=token&e=timestamp
what I'm trying to do is:
location /secure/(?<token>)/(?<timestamp>)/(?<path>) {
rewrite ^ /s/$path/?st=$token&e=$timestamp
}
but it's obviously not working. This syntax doesn't seemed to be correct. How can I play like this with urls in nginx rules?
EDIT: trying now something like this: the same result:
location /secure/(.*)/(.*)/(.*) {
rewrite ^ /s/$3?st=$1token&e=$2timestamp;
}
Upvotes: 1
Views: 220
Reputation: 49722
You have multiple problems. You have confused prefix locations with regex locations. Your named captures do not contain any content. And your numeric captures are probably too broad.
See this for location syntax.
You should probably use a prefix location, then capture in the rewrite:
location /secure/ {
rewrite ^/secure/([^/]*)/([^/]*)/(.*)$ /s/$3?st=$1&e=$2 last;
}
Upvotes: 1