问题
I want to block access to urls that have excess characters at its end.
E.g. I want nginx to block requests to https://www.example.com/url-pattern/amp/extra-chars/more-extra
but want it to allow https://www.example.com/url-pattern/amp
or https://www.example.com/url-pattern/amp/
Will this work?
location .*\/amp\/. {
deny all
}
Please guide.
回答1:
Solved it myself. If anyone is looking for the same solution
location ~* /amp/. {
deny all;
}
来源:https://stackoverflow.com/questions/62984495/regex-to-block-url-in-nginx