These are present to ensure that the entire URL is matched when performing the rewrite.
For example, without the ^
, these URLs would match:
/admin/users/foo
/whatever/users/bar
In this case, the $
isn't really required because the *
is greedy (.
matches anything and the *
matches as much as possible). This results in the expression matching the remaining input even without the $
. In a more restricted case such as:
rewrite ^/users/dan$ /show?user=dan last;
The $
is important for the same reason. Without it, these URLs would match:
/users/dan/delete
/users/dan/profile
/users/danny
But with it, only the exact url /users/dan
would match.