I want to return all requests to urls that contains the string Histats to 404. How can I do that?
Asked
Active
Viewed 3.7k times
5
-
What pattern you are looking for /Histats/* ? – AllTooSir Jun 20 '13 at 18:50
-
I am looking for * Histats * – Kaah Jun 20 '13 at 19:01
-
8`if ($request_uri ~ .*Histats.*) { return 404; }` Works fine. – Kaah Jun 20 '13 at 21:31
-
1Thanks to your comment I was able to solve this major headache. https://stackoverflow.com/questions/51747175/nginx-location-match-regex-for-special-characters-and-encoded-url-characters – MitchellK Aug 09 '18 at 12:03
1 Answers
16
location ~ Histats {
return 404;
}
PS: If is evil

Mohammad AbuShady
- 40,884
- 11
- 78
- 89
-
-
2yea, but I think you need to use a block for that `location ~ (Histats|test)` – Mohammad AbuShady Jun 26 '13 at 23:03