85

What is the meaning of the tilde after the location block in the nginx configuration?

for example

location ~ ^/download/(.*)$ {
  alias /home/website/files/$1;
}

What is the difference between with and without the "~" ?

2

1 Answer 1

91

The tilde instructs nginx to perform a case-sensitive regular expression match, instead of a straight string comparison.

More details in the docs.

1
  • 3
    Additionally, ~* modifier for case-insensitive reg exp matching and ^~ modifier to override possible matches elsewhere. Commented Nov 20, 2020 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .