Dangeruss
Dangeruss

Reputation: 73

nginX matching path after host

I'm trying to implement the following rule:

location ~ ^/stylesheets|javascripts|assets/ 

However it's matching against:

mysite.com/something/something/javascripts

My thought was this simple regex would only match.

mysite.com/javascripts

I want it to ignore nesting, what is wrong here?

Upvotes: 0

Views: 973

Answers (1)

user507077
user507077

Reputation:

You have to group the OR'ed expression: ^/(stylesheets|javascripts|assets)/

Otherwise you'd have three slightly different potential matches:

  1. Any path starting with /stylesheets,
  2. Any path containing javascripts somewhere and
  3. Any path containing assets/ anywhere.

Upvotes: 3

Related Questions