Configuring nginx to return a 404 when a URL matches a pattern

shanqn picture shanqn · Jan 12, 2011 · Viewed 86.9k times · Source

I want nginx to return a 404 code when it receives a request which matches a pattern, e.g., /test/*. How can I configure nginx to do that?

Answer

Vicheanak picture Vicheanak · Jan 13, 2011
location /test/ {
  return 404;
}