regex – Decline all URIs with tilde character in Nginx
I would like to return a 403 whenever a request contains a tilde character (~)
Example: https://example.com/~/item-1/ or even. https://example.com/item1?status=~pending
I want the above to return a 403
My idea is to have something like the config below, but I’m not sure how to complete the regex part.
map $request_uri $filefromarg {
[WHAT-REGEX-HERE];
default $request_uri;
}
try_files $filefromarg $uri =403;
Kindly share how to do this and the possible regex pattern.
Read more here: Source link
