57149

nginx location regex, match multiple times

<h3>Question</h3>

How to match multiple times in nginx location regex ?

it seems the {x,x} syntax never works!

for example:

location ~ ^/abc/\w{1,3}$ { ... }

nerver work!


<h3>Answer1:</h3>

You must quote location which contains { or ; characters.

location ~ "^/abc/\w{1,3}$" { ... }

otherwise nginx parse it as location ~ ^/abc/\w { 1, ... and fails with syntax error.

来源:https://stackoverflow.com/questions/25764027/nginx-location-regex-match-multiple-times

Recommend

  • Rally - clone existing app
  • FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndarray with 'datetime
  • Using ExecutorService with a multithreaded version of Merge Sort
  • Scala: Re-use generic resulting from path-dependent type in path-dependent context
  • Progressive cart item fee based on state and on product category in Woocommerce
  • Deploy WAR file in Tomcat, Issue after Deployment
  • How to make html video autoplay on phones and tablets?
  • How do I use RestSharp to POST a login and password to an API?
  • Why does IntStream.range(0, 100000).parallel.foreach take longer then normal for loop
  • Adding a delete button in PHP on each row of a MySQL table
  • JQuery and PHP validation problem?
  • Storyboard iOS MBProgressHUD
  • Reshape dataframe to dataframe with unlimited rows and filling zeroes where no values
  • NHibernate - Paging with ICriteria and optional ICriteria calls
  • Symfony 2:image paths in javascript file with assetic
  • Django IN query as a string result - invalid literal for int() with base 10
  • Highlight special word in a TextBox
  • Microsoft bot framework webchat C#
  • Retrieving Application's DisplayName/UninstallString from Registry Using Powershell
  • Laravel Query Builder Update with Increment
  • How to create wsdl from xsd
  • Calculate savings percentage for house down payment in 36 months
  • date changes on export kendoGrid
  • iOS App crash issue `[UIWindow warpPoint:]`
  • Expression.Call GroupBy then Select and Count()?
  • SyntaxError: expected expression, got '.'
  • Slick: How can I combine a SQL LIKE statement with a SQL IN statement
  • $this->a->b->c->d calling methods from a superclass in php
  • dmtracedump doesn't work, HELP!
  • Bundling python(“.py”)files along with java class files for a web application
  • How to process remote XML files with XSLT
  • Modifying native query cannot have named parameter bindings?
  • Find all parks for a given zipcode with google maps
  • Unable to start a WebView from an AsyncTask
  • C# code can't “see” the methods in my C++ dll
  • Request Access Token in Postman for Azure Function App protected by Azure AD B2C
  • All Event listing on specified date in Google Calender api (V3) in java?
  • ASP.NET MVC 2 actions for the same route?
  • How to run chrome.tabs.insertCSS from the background page on each page?
  • ReferenceError: TextEncoder is not defined