Understanding Nginx Location Directive

Here are Location Block syntax:

  • (none): The location_match is interpreted as a prefix match.
  • =: The location_match is interpreted as a exactly match.
  • ~: This location_match will be interpreted as a case-sensitive regular expression match.
  • ~*: The location_match block will be interpreted as a case-insensitive regular expression match.
  • ^~: The location_match is interpreted as the best non-regular expression match, regular expression matching will not take place.

Examples:

2. prefix matching

/site, /site/page1, or /site/index.html

2. exact request URI matching

3. case-sensitive regular expression

4. case-insensitive regular expression

5. prevent regular expression matching

 

Leave a Reply

Your email address will not be published. Required fields are marked *