Nginx Learning notes 04URL matching rules and actual paths

Source: Internet
Author: User
Tags nginx server

1.1.1. URL matching rules

Matching rule Configuration Summary:

Location [=|~|~*|^~]/uri/{}

Priority level

Matching method

Describe

1 Maximum

=

Exact match.

2

^~

Start with a string, pure string, regular expression not supported

3

~*

Regular expression matching, case-insensitive

3

~

Regular expression matching, case-sensitive

3

!~*

Regular expressions do not match, case-insensitive

3

!~

Regular expression mismatch, case-sensitive

4 min

/

Generic match, matching all paths that do not match the preceding criteria

when multiple location nodes with the same priority match the URL of a request , the top matching success occurs in the configuration file.

1.1.2. configuration of the actual path

in processing URL requests, there are many different configurations for the corresponding actual paths.

How to configure

Describe

Root

Nginx Root of the server, default to html catalogue.

For example:

location/abc/

Root  /opt/nginx/html

Request: /abc/1.txt

Actual path:

/opt/nginx/html/abc/1.txt

Alias

The root directory of the Nginx server will remove that part of the location.

Alias can use regular expressions, you can use The grouping $1,$2,$3 in the location regular expression , and so on.

location/abc/

Alias/opt/nginx/html

Request:/abc/1.txt

Actual path:

/opt/nginx/html/1.txt

Index

Define the first page. You can separate multiple home files with spaces.

Index index.html index.jsp index.php

Error_page

Error page redirection. Multiple redirection methods.

Nginx Learning Notes 04URL matching rules and actual paths

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.