2012-03-16 62 views
1

我的主機文件。 (Win 7的終極)Windows 7 - XAMPP:vhost保持重定向

127.0.0.1  localhost 
127.0.0.1  efmm.local 

我的httpd-vhosts.conf(XAMPP 1.7.3)

NameVirtualHost 127.0.0.1:80 

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

    <VirtualHost efmm.local> 

     DocumentRoot "C:\xampp\htdocs\EFMM" 
     ServerName efmm.local  
     ErrorLog "logs/efmm.localhost-error.log" 
     CustomLog "logs/efmm.localhost-access.log" combined 
     <Directory "C:\xampp\htdocs\EFMM"> 
     Options Indexes FollowSymLinks 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
     </Directory> 

    </VirtualHost> 

問題

當我去efmm.local,將瀏覽器重定向到localhost/EFMM。 我也試過<VirtualHost 127.0.0.1:80>而不是<VirtualHost efmm.local>,結果相同。

回答

1

這裏是我如何做到這一點的XP(不要指望它做在7任何區別)

首先,虛擬主機的域名添加到您的主機(像你一樣)

我不將虛擬主機webroot放在主htdocs目錄下。我創建它旁邊一個特定的根目錄,這給了我下面的樹:

  • C:\ XAMPP \ htdocs中
  • C:\ XAMPP \ htdocs目錄,seconddomain
  • C:\ XAMPP \ htdocs目錄,指向ThirdDomain

等。

你的情況

所以,我會創造C:\ XAMPP \ htdocs目錄,EFMM一起C:\ XAMPP \ htdocs中

然後:

編輯XAMPP的httpd.conf中,添加並定義新的文檔根目錄任何Apache選項,即:

<Directory "C:/XAMPP/htdocs-efmm"> 
Options Indexes FollowSymLinks Includes ExecCGI 
AllowOverride All 

[any extra apache module instructions you may require] 

Order allow,deny 
Allow from all 
</Directory> 

編輯XAMPP的的httpd-vhosts.conf,添加虛擬主機:

<VirtualHost *:80> 
ServerName efmm.local 
ServerAlias www.efmm.local 
DocumentRoot "C:/XAMPP/htdocs-efmm" 
ErrorLog "C:/XAMPP/htdocs-efmm/error.log" 
DirectoryIndex index.php index.html index.htm 
</VirtualHost> 

重新啓動XAMPP。您現在可以瀏覽您的新虛擬主機。