如何访问在一个XAMPP的虚拟主机的DocumentRoot以外的文件? [英] How to access files outside the DocumentRoot in a VirtualHost in XAMPP?
问题描述
我在Windows 7中配置的虚拟主机项目位于 C:\\项目
结构如下:
I have a Virtual Host configured in Windows 7. The project is located in C:\project
with the following structure:
project
\cache
\configs
\htdocs
\css
\images
\js
\.htaccess
\index.php
\includes
\setup.php
\en.php
\lib
\templates
\templates_c
在我的的httpd-vhosts.conf
,我创建了一个虚拟主机:
In my httpd-vhosts.conf
, I created a VirtualHost:
<VirtualHost *:80>
DocumentRoot "C:/project/htdocs"
ServerName project.dev
<Directory "C:/project/htdocs">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
和增加 127.0.0.1 project.dev
到 C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机
。
问题是我想要的的htdocs
是目录从的httpd
将成为文件,但我想包括,使用PHP,文件,例如,位于包括
目录
The problem is that I want the htdocs
to be the directory from which httpd
will serve files but I want to include, with PHP, files, for example, located in the includes
directory.
我该如何解决这个问题?我已经从 $尝试了许多解决方案_ SERVER ['DOCUMENT_ROOT']
Apache的别名和的.htaccess
调整,但没有一个到目前为止的工作。一定有一些简单的解决方案。也许我不理解十分正确的DocumentRoot的概念。我只是想模仿典型的服务器文件夹的public_html /网络/ htdocs目录
,同时保持重要的文件进行浏览器/用户范围。
How can I solve this problem? I already tried so many solutions from $_SERVER['DOCUMENT_ROOT']
to Apache Alias and .htaccess
tweaking but none have worked so far. There must have be some easy solution. Maybe I'm not understanding quite correctly the concept of DocumentRoot. I just want to emulate the typical server folder public_html/www/htdocs
while keeping important files out of the browser/user scope.
推荐答案
这是一个虚拟主机我从的httpd-vhosts.conf了
。我做的唯一额外的配置是让403围绕我打:
This is a VHost I took from my httpd-vhosts.conf
. The only extra configuration I made was to get around the 403 I was hitting:
<VirtualHost *:80>
ServerName "Markdown.loc"
ServerAlias "www.Markdown.loc"
DocumentRoot "C:\INTERNAL\PHP\Markdown"
<Directory "C:\INTERNAL\PHP\Markdown">
Options +Indexes
AllowOverride All
</Directory>
</VirtualHost>
我的所有其他虚拟主机是这样的:
All my other VHosts look like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/somesite.loc"
ServerName somesite.loc
ServerAlias www.somesite.loc
</VirtualHost>
如果你只是希望包括从目录上同一级别的htdocs中的东西,虽然,包括(../包括/ somefile.php)
应该只是罚款。
If you're simply looking to include something from a dir on the same level as your htdocs though, include("../includes/somefile.php")
should work just fine.
如果我有你的问题错了,让我知道,我会尽力帮助你。
If I've got your problem wrong, let me know, and I'll try to help you more.
这篇关于如何访问在一个XAMPP的虚拟主机的DocumentRoot以外的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!