Reputation: 3927
in my server
directive, the location configuration are as below
location ~ \.(html)$ {
expires max;
return 200 "case sensitive match";
}
location ~* \.(html)$ {
expires 10d;
return 200 "case insensitive match";
}
My expectation is that when I load localhost/somthing.html
it should print case sensitive match
and when I load localhost/something.hTML
it should print case insensitive match
However, in both the cases, case sensitive match
gets printed
The request log in access.log
is
127.0.0.1 - - [18/Apr/2021:17:56:15 +0530] "GET /something.hTML HTTP/1.1" 200 20 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15"
Attached picture, see the statement printed and also the expires
which is set to MAX
proving that case sensitive match
worked. What could be going wrong here?
Upvotes: 1
Views: 401
Reputation: 2095
location ~
matches are still case-insensitive under operating systems with case-insensitive filesystems (such as Mac OS & Windows).
To force a case-insensitive pattern you need to include it in the regex itself with (?-i)
e.g.
location ~ "(?-i)\.(html)$" {
...
}
Upvotes: 2