4

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 Answer 1

13

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

location ~* /amp/. {
 deny all;
}
Sign up to request clarification or add additional context in comments.

3 Comments

Where was this applied? Please, Thanks
You can apply it to your nginx config files where location rules are specified.
i want rule, if someone enter "/amp/123" it should return 403, everything except "/amp/" shoud return 403

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.