Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx location tilde

What is the tilde (~) doing in an Nginx Location directive? ie:

location ~* \.(png|gif|jpg)$ {
  [...configuration]
}
like image 867
Cory Robinson Avatar asked Aug 01 '16 14:08

Cory Robinson


People also ask

What does tilde mean in nginx?

~: The tilde sign is used for case-sensitive regular expression match against a requested URI. ~*: The tilde followed by asterisk sign is used for case insensitive regular expression match against a requested URI.

Where is nginx location directive?

NGINX Configuration: Understanding Directives. Every NGINX configuration file will be found in the /etc/nginx/ directory, with the main configuration file located in /etc/nginx/nginx.

Where is nginx installed?

By default, NGINX will be installed in /usr/local/nginx . You may change this and other options with the Installation and Compile-Time Options.

Where is nginx HTML folder?

It is located in /usr/share/nginx/html. Save this answer.


1 Answers

The tilde (~) is an identifier for Nginx letting it know that the location block is using a REGEX to match the location.

"~" = REGEX match, case-sensitive

"~*" = REGEX match, case-insensitive

Nginx Docs

like image 179
Cory Robinson Avatar answered Oct 08 '22 23:10

Cory Robinson