2

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.

LittleLebowski
  • 7,691
  • 13
  • 47
  • 72

1 Answers1

9

Solved it myself. If anyone is looking for the same solution

location ~* /amp/. {
 deny all;
}
LittleLebowski
  • 7,691
  • 13
  • 47
  • 72