如何在XAMPP中的VirtualHost中访问DocumentRoot之外的文件?

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

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>

And added 127.0.0.1 project.dev to the C:\Windows\System32\drivers\etc\hosts.

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.

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.

查看全部
dpdrtj1075
dpdrtj1075
2013/03/03 03:05
  • apache
  • php
  • xampp
  • virtualhost
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复