如何使 htdocs 内的目录充当根目录?
例子:
即将 "localhost/<directory>"
供应 "C:/Apache/htdocs/<directory>"
作为"$_SERVER['DOCUMENT_ROOT']"
我试过了,但这并没有改变"$_SERVER['DOCUMENT_ROOT']"
<VirtualHost localhost/<directory>:80>
DocumentRoot C:\Apache\htdocs\<directory>
ServerName localhost/<directory>
ServerAlias localhost/<directory>
<Directory "C:\Apache\htdocs\<directory>">
AllowOverride All
Require local
</Directory>
</VirtualHost>
答案1
不要混淆 Apache虚拟的目录(如http://服务器名称/目录)和物理路径(例如 c:\folder)
<VirtualHost localhost:80> <-- this is where the apache
process listens (just
servernames/ips/ports)
DocumentRoot C:\Apache\htdocs\<directory>
<-- This path is served in the virtual directory "/"
(and what you are searching for)
ServerName localhost
<-- This is the server's name on which this directive is active
ServerAlias localhost
<-- Theese are alternate server's names. NAMEs, no path at all.
</VirtualHost>
该指令在这里不做任何与虚拟路径有关的事情;它包含的内容如何apache 应该在这个目录中运行,而不是在它所在的位置运行。