【发布时间】:2013-06-11 19:39:56
【问题描述】:
我目前在以下位置安装 WAMP:
C:/wamp/www/
我的问题:
当从localhost/projectname1/test.php 调用$_SERVER['DOCUMENT_ROOT']; 时 - 输出:
C:/wamp/www/
这不好,因为我的脚本中的路径将是错误的。在这种情况下,我希望 Document root 输出(这是我这个虚拟项目的别名路径):
C:\Users\SGS\Google Drive\_Work\projectname1\html/
我所有的工作文件都在谷歌驱动器上,所以我为每个项目创建一个 Apache 别名,它指向位于谷歌驱动器文件夹中的项目的直接路径。
创建的别名示例 - projectname1.conf:
Alias /projectname1/ "C:\Users\SGS\Google Drive\_Work\projectname1\html/"
<Directory "C:\Users\SGS\Google Drive\_Work\projectname1\html/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
这允许我使用localhost/projectname1/ 调用项目
如何获取我的文档?
【问题讨论】:
-
嗨莎拉,谢谢你的建议。我实际上已经尝试过这个 - 但是这个问题是它会使文档根“静态”并且无论项目文件夹如何都引用: C:/Users/SGS/Google Drev/_Work/ 。在我的一个项目示例中 - 文档根需要引用 C:\Users\SGS\Google Drive_Work\projectname1\html/
-
所有 DOCUMENT_ROOT 包含的是来自服务器配置文件的信息。 PHP 不会像这样遵循 WAMP 的别名。您可以尝试解构其他 $_SERVER 变量之一,如下所示:stackoverflow.com/questions/4634869/…
标签: apache wamp alias wampserver document-root