I copied that from your last example and didn't look at your original post.The rewrite line explained:
- The first part ^(.*) is a regular expression that will grab everything from the start of the URI path to the end. The ^ symbol matches the start of the string, . matches any character, and as you said * means "the previous character zero or many times". The parentheses around it form a capturing group so we can reuse it later
- The second part $1 refers to that capturing group.
To go back to your original post, I think this should be the correct version:
location /component/ {
rewrite ^/component/(.*) /$1 last;
}
So if we break this down:
- if the path is /component/abc/categories, we should end up in the location block because it starts with /component
- the write rule will match ^/component/(.*) - meaning that abc/categories should be captured
- we then rewrite the path /component/abc/categories to simply /abc/categories
Let me know if that works :)
Cheers,
Steven