nginx 配置示例_Nginx位置指令示例

本文详细介绍了NGINX的location指令,包括其语法、选择位置块的逻辑以及各种匹配示例,如精确匹配、正则表达式匹配等,帮助理解如何在文件系统中路由请求。
摘要由CSDN通过智能技术生成

nginx 配置示例

The location directive within NGINX server block allows to route request to correct location within the file system.

NGINX服务器块中的location指令允许将请求路由到文件系统中的正确位置。

The directive is used to tell NGINX where to look for a resource by including files and folders while matching a location block against an URL. In this tutorial, we will look at NGINX location directives in details.

该指令用于通过包含文件和文件夹,同时将位置块与URL匹配,来告诉NGINX在哪里寻找资源。 在本教程中,我们将详细介绍NGINX位置指令。

先决条件 (Prerequisite)

  • You have already installed NGINX by following our tutorial from here.

    您已经按照此处的教程安装了NGINX。

NGINX位置指令语法 (NGINX location directive syntax)

The NGINX location block can be placed inside a server block or inside another location block with some restrictions.

NGINX位置块可以在某些限制下放置在服务器块内或另一个位置块内。

The syntax for constructing a location block is:

构造位置块的语法为:

location [modifier] [URI] {
  ...
  ...
}

The modifier in the location block is optional. Having a modifier in the location block will allow NGINX to treat a URL differently. Few most common modifiers are:

位置块中的修饰符是可选的。 在位置块中使用修饰符将使NGINX可以不同地对待URL。 很少有最常见的修饰符是:

  • none: If no modifiers are present in a location block then the requested URI will be matched against the beginning of the requested URI.

    none :如果位置块中没有修饰符,则所请求的URI将与所请求的URI的开头进行匹配。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值