1

I noticed in my error logs that some requests for favicon.??? are looking for the file in various directories (not root). I used "grep" and checked my server files and all meta tags, etc - and they all point to /favicon.ico

So I solved this issue by doing this :

location ~* favicon\.(.*) {
    expires   365d;
    etag      on;
    try_files /favicon.ico =404;
}

What I would like to do is use the following prefix so my other regexp locations are not searched :

location ^~ favicon\.(.*)

However, that does not work and never matches, even for /favicon.??? requests.

Is it possible to use the "^~" prefix and still have it match for "favicon.???" in ANY directory request?

1 Answer 1

1

The ^~ modifier affects the behaviour of prefix locations. It is not a regex location.

To make your location ~* favicon\. match before your other regex locations, simply make it the first regex location encountered in the server container.

See this document for details.

1
  • Thank you. Any ideas how many regex locations one can have in a server block before it starts to impact performance?
    – Dave
    Jan 31, 2016 at 5:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .