What is the difference between:
location = /abc {}
and
locaton ~ /abc {}
To find a location match for an URI, NGINX first scans the locations that is defined using the prefix strings (without regular expression). Thereafter, the location with regular expressions are checked in order of their declaration in the configuration file.
Nginx Location directive allows routing requests to a particular location in the file system. While Nginx is matching or searching a location block against the requested URL, the location directive tells the Nginx where to search for a specific path by including all files and directories.
nginx location block doesn't match query string at all. So it's impossible. This directive allows different configurations depending on the URI.
Every NGINX configuration file will be found in the /etc/nginx/ directory, with the main configuration file located in /etc/nginx/nginx. conf . NGINX configuration options are known as “directives”: these are arranged into groups, known interchangeably as blocks or contexts .
location = /abc {}
matches the exact uri /abc
location ~ /abc
is a regex match on the uri, meaning any uri containing /abc
,
you probably want: location ~ ^/abc
for the uri begining with /abc
instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With