7

Is there a difference between the 3 following directives?

location ~* \.(png)$ {
  expires max;
  log_not_found off;
}

location ~ \.(png)$ {
  expires max;
  log_not_found off;
}

location ~ .(png)$ {
  expires max;
  log_not_found off;
}

Thank you in advance for having taken the time thus far.

The Dude man
  • 383
  • 6
  • 19

1 Answers1

4

These are three forms of regular expression location block. See this document for details.

The ~* operator makes the test case insensitive.

The . character has a special meaning in a regular expression: matching any single character (much like ? does in shell globs).

The \. sequence (an escaped dot) matches a literal dot character. This means the third example is probably not what you want (assuming you are attempting to match URIs ending with .png).

See this document for more on regular expressions.

Richard Smith
  • 45,711
  • 6
  • 82
  • 81