Apache 安装后,默认的 DocumentRoot 是安装目录下的 htdocs 目录,编程时有很多不便,如需更改,打开安装目录 conf 子目录下的 httpd.conf 文件,修改 DocumentRoot 属性即可,如更改为:DocumentRoot “E:/My/DocRoot”。
在 IIS 下,新建虚拟目录可通过可视化界面操作,在 Apache 中,新建虚拟目录通过修改 httpd.conf 文件实现。
在 httpd.conf 的 alias_module 下增加一别名定义项,如:Alias “/onefly” “E:/My/Onefly” ,即可定义虚拟目录。
更改以上设置后,必须重启 Apache 才能使设置生效。同时,要对相应目录作权限定义,否则会出现无权访问的错误提示。
要对目录定义权限,可在 httpd.conf 文件中定义类似以下的代码:
<Directory “E:/My/Onefly”>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
=======================================================================
自己机器上配置实例如下:
<IfModule alias_module>
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.waydu.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
##################################################################
Alias /study "D:/PHP/www/study"
<Directory "D:/PHP/www/study">
Options Indexes Includes FollowSymLinks MultiViews IncludesNoExec
AllowOverride None
Order allow,deny
Allow from all
</Directory>
##################################################################
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.waydu.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
##################################################################
Alias /study "D:/PHP/www/study"
<Directory "D:/PHP/www/study">
Options Indexes Includes FollowSymLinks MultiViews IncludesNoExec
AllowOverride None
Order allow,deny
Allow from all
</Directory>
##################################################################
分类:
012~apache
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)