-2

How can I write an Nginx regexp mathing location containg foo|bar|baz or ending with /beautifu.html?

sth like location ~ ^/.*(foo|bar|baz)/.*$ but also matching .*/beautiful.html

bastiat
  • 1,799
  • 2
  • 19
  • 38
  • 2
    The `|` operator is used to separate alternative regular expressions. The `^/.*` and the `.*$` is unnecessary. You could try: `location ~ (foo|bar|baz)/|/beautiful.html$ { ... }` – Richard Smith Jul 20 '20 at 12:24

1 Answers1

-1

Just add /beautifu.html before the dollar sign to make sure the URL ends with /beautifu.html

Vincent
  • 3,945
  • 3
  • 13
  • 25
  • 1
    (Re)read the question:“location contains `foo|bar|baz` **or** ends with `/beautiful.html`” – Toto Jul 20 '20 at 12:24