我可以通过浏览器访问Apache,http://localhost
或http://127.0.0.1
访问D:ApplicationsXAMPPhtdocs
根目录下的php文件。但是,我可以导航到http://127.0.0.1/projects/
或http://localhost/projects/
来访问D:Documentsprojects
中的文件。但? 我是如何配置它的?
据我所知,我在D:ApplicationsXAMPPapacheconfhttpd.conf
中没有别名。文档路由仍然是htdocs
,在同一个文件(D:ApplicationsXAMPPapacheconfhttpd.conf
)中。我在D:ApplicationsXAMPPapacheconfextrahttpd-vhosts.conf
中没有虚拟主机。
Windows通过文本文件搜索无法在D:ApplicationsXAMPPapache
文本文件中找到任何对搜索词/projects
(或projects
)的引用。
我在哪里通过导航到http://localhost/projects/
将D:Documentsprojects
定义为Apache的可访问文件夹?
问了不到5分钟,经过几个小时的努力,我突然找到了答案。
我有别名。
在D:ApplicationsXAMPPapacheconfhttpd.conf
中,我写了Include "conf/alias/*.conf"
行,这意味着我可以在D:applicationsxamppapacheconfalias
中定义别名,例如'D:applicationsxamppapacheconfaliasprojects.conf',其中定义了D:Documentsprojects
的基本别名,代码为:
<Directory "D:/Documents/projects">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
Alias /projects "D:/Documents/projects"