简体   繁体   English

Apache HTTPD虚拟主机,文档根目录中的%1 +是什么?

[英]Apache HTTPD Virtual Host,what is %1+ in a document root?

So I have a Virtual Host set up and I snagged this as my Document Root 因此,我设置了虚拟主机,并将其作为我的文档根目录

VirtualDocumentRoot "/sites/%1+/www"

Everything works great but this one thing has been killing me. 一切都很好,但是这一件事已经使我丧命。 Does anyone have any idea what %1+ means? 有谁知道%1 +是什么意思? Could someone breakdown exactly what it is and how it works. 有人能确切地解释它是什么以及它如何工作。 I understand it is pointing the server to where to look but what is %1+ doing? 我了解它是将服务器指向何处,但是%1+在做什么?

Read the documentation: http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html 阅读文档: http : //httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html

All the directives in this module interpolate a string into a pathname. 此模块中的所有指令都将字符串插入到路径名中。 The interpolated string [...] may be either the server name [...] or the IP address of the virtual host on the server in dotted-quad format. 插值字符串可以是服务器名称,也可以是点分四进制格式的服务器上虚拟主机的IP地址。 The interpolation is controlled by specifiers inspired by printf which have a number of formats: 内插由受printf启发的说明符控制,这些说明符具有多种格式:

 [...] %NM insert (part of) the name 

N and M are used to specify substrings of the name. N和M用于指定名称的子字符串。 N selects from the dot-separated components of the name, and M selects characters within whatever N has selected. N从名称的点分隔的部分中选择,并且M在选择的N中选择字符。 M is optional and defaults to zero if it isn't present; M是可选的,如果不存在,则默认为零; the dot must be present if and only if M is present. 当且仅当存在M时,点必须存在。 The interpretation is as follows: 解释如下:

 0 the whole name 1 the first part [...] 2+ the second and all subsequent parts [...] 

For a very large number of virtual hosts it is a good idea to arrange the files to reduce the size of the vhosts directory. 对于大量的虚拟主机,最好安排文件以减小vhosts目录的大小。 To do this you might use the following in your configuration file: 为此,您可以在配置文件中使用以下内容:

 UseCanonicalName Off VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2 

A request for http://www.domain.example.com/directory/file.html will be satisfied by the file /usr/local/apache/vhosts/example.com/d/o/m/domain/directory/file.html. /usr/local/apache/vhosts/example.com/d/o/m/domain/directory/file对http://www.domain.example.com/directory/file.html的请求将得到满足html的。

So, in 所以,在

VirtualDocumentRoot "/sites/%1+/www"

the request 要求

www.example.com

would resolve to 将解决

/sites/www.example.com/www

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM