gpt4 book ai didi

php - 在 Windows 上更改 documentroot for apache 不起作用

转载 作者:搜寻专家 更新时间:2023-10-31 21:15:34 26 4
gpt4 key购买 nike

我正在尝试更改本地 Windows 机器上的 documentroot 以指向 htdocs 下的子目录。我已经更改了 httpd.conf 中的 DocumentRoot 位置以及目录位置。我已经重新启动 Apache,但使用 PHP 打印出文档根目录,它仍然指向默认位置。

httpd.conf 中的更改:

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/folder_test/website"

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/folder_test/website">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

当我导航到 http://localhost/folder_test/website 时我从我的 PHP 输出中看到以下内容:

C:/Program Files/Apache Software Foundation/Apache2.2/htdocs

我的 PHP 代码:

<?php 
//Get the document root
$root = getenv("DOCUMENT_ROOT") ;
Echo $root;
?>

我已经重新启动了 Apache...我错过了什么?

最佳答案

打开“\conf\extra\httpd-vhosts.conf”文件。

改变

<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs"
#ServerName www.example.com:80
</VirtualHost>

反射(reflect)所需目录的部分,在您的情况下:

<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs/folder_test/website"
#ServerName www.example.com:80
</VirtualHost>

关于php - 在 Windows 上更改 documentroot for apache 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9556647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com