Nginx Location Directive

Nginx Location Directive is used to route request to correct files.

Match

Exact match is used to match an exact URL.

When location is used with no modifiers, then beginning of the URL is matched. In this case, any url http://domain/ok/FILE_NAME will be served from /home/ok/FILE_NAME

Exact Match (=)

Exact match is used to match an exact URL.

In this example http://domain/ok/index.html get served from /home/ok/index.html. Only this specific file will be matched.

Cause Insensitive Regular Expression Match (~*)

Above code routes URL http://domain/ok/ to /home/ok/index.html. But won’t match http://domain/OK/.

If you need both /ok and /OK work, you need to use

With this config, http://domain/OK/FILE will be served from /home/OK/FILE.

See Nginx

Add a Comment

Your email address will not be published. Required fields are marked *