XAMPP Windows Apache vhosts无法正确重定向

时间:2014-06-01 15:08:31

标签: apache virtualhost

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost

    <Directory "C:/xampp/htdocs/">
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/gl"
    ServerName gl.dev

    <Directory "C:/xampp/htdocs/gl">
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

以上是我目前在vhosts文件中的内容。当我点击localhost时我希望我的root打开,但是当我加载gl.dev时我希望打开个别站点。有什么想法吗?

主持文件:

    127.0.0.1       localhost
#   ::1             localhost
    127.0.0.1   gl.dev

1 个答案:

答案 0 :(得分:0)

我认为在windows中你必须在指定文档根目录时使用反斜杠。请尝试以下

<VirtualHost *:80>
 ServerName localhost
 ServerAlias *.localhost
 DocumentRoot "C:\xampp\htdocs\"

 <Directory />
  #Options FollowSymLinks
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  Require all granted
 </Directory>
</VirtualHost>


<VirtualHost *:80>
 ServerName gl.dev
 ServerAlias *.gl.dev
 DocumentRoot "C:\xampp\htdocs\gl"

 <Directory />
  #Options FollowSymLinks
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  Require all granted
 </Directory>
</VirtualHost>

重启WAMP服务器