在Windows上更改Apache的documentroot不起作用 [英] changing documentroot for apache on windows isn't working

查看:373
本文介绍了在Windows上更改Apache的documentroot不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改本地Windows计算机上的documentroot,使其指向htdocs下的子目录.我已经更改了httpd.conf中的DocumentRoot位置以及目录位置.我已经重新启动了Apache,但是用PHP优先显示了文档根目录,它仍然指向默认位置.

I'm trying to change documentroot on my local windows machine to point at a sub directory below htdocs. I've changed the DocumentRoot location inside httpd.conf along with the Directory location. I've restarted Apache but prinitng out document root with PHP it still points to the default location.

httpd.conf中的更改:

Changes inside 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输出中看到以下内容:

When I navigate to http://localhost/folder_test/website I see the following from my PHP output:

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

我的PHP代码:

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

我已经重新启动了Apache ...我缺少什么?

I've restarted Apache...What am I missing?

推荐答案

打开"\ conf \ extra \ httpd-vhosts.conf"文件.

Open the "\conf\extra\httpd-vhosts.conf" file.

更改

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

部分以反映所需的目录,具体情况如下:

section to reflect the desired directory, in your case:

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

这篇关于在Windows上更改Apache的documentroot不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆