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.

1

1 Answer 1

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.

1
  • Very much appreciated "Agent Smith"! Jan 22, 2017 at 0:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.