最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

ApacheHTTP服务器2.2文档

来源:懂视网 责编:小采 时间:2020-11-09 15:42:09
文档

ApacheHTTP服务器2.2文档

ApacheHTTP服务器2.2文档:MappingURLstoFilesystemLocations 从 URL 映射到文件系统 DocumentRoot 文档根目录 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(theparto
推荐度:
导读ApacheHTTP服务器2.2文档:MappingURLstoFilesystemLocations 从 URL 映射到文件系统 DocumentRoot 文档根目录 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(theparto

MappingURLstoFilesystemLocations 从 URL 映射到文件系统 DocumentRoot 文档根目录 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(thepartoftheURLfollowingthehostnameandport)andaddittotheendof

Mapping URLs to Filesystem Locations

从 URL 映射到文件系统

DocumentRoot

文档根目录

In deciding what file to serve for a given request, Apache's default behavior is to take

the URL-Path for the request (the part of the URL following the hostname and port) and add it to the end of the DocumentRoot specified in your configuration files.

在决定用什么文件响应一个已经到达的请求时,Apache的默认行为是用url路径来响应请求(这一部分的url地址是跟随在主机名和端口号之后的),并且将它添加到在你的配置文件中确定的文档根目录的结尾。

Therefore, the files and directories underneath the DocumentRoot make up the basic document tree which will be visible from the web.

因此,在根目录下的文件和目录将会使服务器的目录结构对于互联网变得可见。

For example, if DocumentRoot were set to /var/www/html then a request for http://www.example.com/fish/guppies.html would result in the file /var/www/html/fish/guppies.html being served to the requesting client.

例如,如果根目录被设置为/var/www/html,之后一个http://www.example.com/fish/guppies.html的网页请求将使文件/var/www/html/fish/guppies.html被送达给请求客户端。

Apache is also capable of Virtual Hosting, where the server receives requests for more than one host.

Apache也可能是虚拟的主机,此时服务器为超过一个主机接收服务请求。

In this case, a different DocumentRoot can be specified for each virtual host, or alternatively, the directives provided by the module mod_vhost_alias can be used to dynamically determine the appropriate place from which to serve content based on the requested IP address or hostname.

在这种情况,可以为每一个不同的虚拟主机设置不同的根目录,或者采用另一种方法,由模块mod_vhost_alias提供的命令可以用于动态确定服务内容(基于ip地址或者主机名请求)所在的位置。

The DocumentRoot directive is set in your main server configuration file (httpd.conf) and, possibly, once per additional Virtual Host you create.

每当你新建一个额外的虚拟主机的时候,文档根目录指令将会在你的主服务器配置文件(httpd.conf) 里被设置。

Files Outside the DocumentRoot

在文档根目录之外的文件

There are frequently circumstances where it is necessary to allow web access to parts of the filesystem that are not strictly underneath the DocumentRoot.

经常有一些情况,有必要允许网页连接到一些不严格位于根目录之下的文件系统。

Apache offers several different ways to accomplish this.

Apache 提供了几种完成这种工作的方法。

On Unix systems, symbolic links can bring other parts of the filesystem under the DocumentRoot.

在unix系统中,符号链接可以使其他部分的文件系统位于文档根目录之下。

For security reasons, Apache will follow symbolic links only if the Options setting for the relevant directory includes FollowSymLinks or SymLinksIfOwnerMatch.

出于安全的原因,Apache只有在相关目录FollowSymLinks或者SymLinksIfOwnerMatch被设置的情况下,才会使符号链接有效。

Alternatively, the Alias directive will map any part of the filesystem into the web space. For example, with

Alias /docs /var/web

the URL http://www.example.com/docs/dir/file.html will be served from /var/web/dir/file.html.

另一种方法,把Alias目录被映射到其他部分的文件系统。例如,

Alias /docs /var/web

url地址为http://www.example.com/docs/dir/file.html 的页面请求将用/var/web/dir/file.html页面来响应请求。

The ScriptAlias directive works the same way, with the additional effect that all content located at the target path is treated as CGI scripts.

Alias脚本命令以同样的方式运行。使用附加的效果:所有位于目标路径的内容被当作CGI脚本

For situations where you require additional flexibility, you can use the AliasMatch and ScriptAliasMatch directives to do powerful regular expression based matching and substitution. For example,

在你需要更灵活的情况下,AliasMatch 和 ScriptAliasMatch命令可以让你使用基于匹配和替换的正则表达式。例如,

ScriptAliasMatch ^/~([a-zA-Z0-9]+)/cgi-bin/(.+) /home/$1/cgi-bin/$2

will map a request to http://example.com/~user/cgi-bin/script.cgi to the path /home/user/cgi-bin/script.cgi and will treat the resulting file as a CGI script.

将会映射http://example.com/~user/cgi-bin/script.cgi的页面请求为/home/user/cgi-bin/script.cgi,并且将最后的文件视为一个CGI 脚本。

User Directories

用户目录

Traditionally on Unix systems, the home directory of a particular user can be referred to as ~user/. The module mod_userdir extends this idea to the web by allowing files under each user's home directory to be accessed using URLs such as the following.

一般来说,在unix系统上,一个用户的主目录可以以~user/来引用。模块mod_userdir 拓展这个思想到了网络,它允许通过url地址来访问位于用户主目录下的文件。如下:

http://www.example.com/~user/file.html

For security reasons, it is inappropriate to give direct access to a user's home directory from the web. Therefore, the UserDir directive specifies a directory underneath the user's home directory where web files are located. Using the default setting of Userdir public_html, the above URL maps to a file at a directory like

/home/user/public_html/file.html where /home/user/ is the user's home directory as specified in /etc/passwd.

出于安全方面的考虑,从网络上直接可以访问用户主目录是不合适的。因此,UserDir命令指定一个位于用户主目录之下的目录用于存放网页文件。使用默认的Userdir public_html设置,上述的url将被映射到某个文件夹下某个的文件,例如:

/home/user/public_html/file.html 。/home/user/是用户的主目录,在/etc/passwd.中被指定。

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

ApacheHTTP服务器2.2文档

ApacheHTTP服务器2.2文档:MappingURLstoFilesystemLocations 从 URL 映射到文件系统 DocumentRoot 文档根目录 Indecidingwhatfiletoserveforagivenrequest,Apache'sdefaultbehavioristotake theURL-Pathfortherequest(theparto
推荐度:
标签: 文件 文档 服务器
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top