The picture above is a simple example that I configured according to the nginx longest match principle. The purpose is to deny all access to /, but to be able to jump normally when accessing /hello. However, for cashback, access to /hello is still 403, but The rewrite log records that nginx did match my rules, why did it still return 403 to me? Please help me understand, thank you very much!
location / can match all requests
You can modify it as follows
Grammar rules: location [=|~|~*|^~] /uri/ { … }
= The beginning means an exact match
^~ The beginning means the uri starts with a regular string, which can be understood as matching the url path. nginx does not encode the URL, so the request is /static/20%/aa, which can be matched by the rule ^~ /static/ /aa (note the space). The beginning of
~ indicates case-sensitive regular matching
~* The beginning indicates case-insensitive regular matching
!~ and !~* are case-sensitive non-matching and case-insensitive non-matching regular matching respectively
/ universal matching, Any request will be matched
Because /test00 after rewrite matches location /
You should add a location ~ ^/test00 and enable access