乍一看,您的 vhost 配置有一些奇怪的地方:
- 第一个文档根目录没有关闭"
- 虚拟主机名称应该相同
- 您指的是 webroot,而不是 approot(您的 approot 中还有一个 .htacces)
我将 CakePHP 2.x 与 wamp 服务器一起使用,配置如下:
确保在您的 apache 配置中取消注释 vhost 文件:wamp/bin/apache/Apache[version]/conf/httpd.conf(或左键单击 wamp->apache->httpd.conf)
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
在 wamp/bin/apache/Apache[version]/conf/extra/httpd-vhosts.conf 试试这个
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName client1.localhost
DocumentRoot "D:\wamp\app1"
<Directory "D:\wamp\app1">
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
<VirtualHost *:80>
ServerName dev.localhost
DocumentRoot "D:\wamp\www\cakephp\app2"
<Directory "D:\wamp\www\cakephp\app2">
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
并将其放入您的主机文件(C:\windows\system32\drivers\etc)
127.0.0.1 localhost
127.0.0.1 dev.localhost
127.0.0.1 client1.localhost
重新启动所有服务。App2 将在 localhost 和 dev.localhost 上可用