2011-10-19 77 views
0

我使用Xampp,並且我想test.localhost轉到127.0.0.1:81Apache VirtualHost:如何ServerName一個不同於80的端口

在httpd.conf中我寫道:

Listen 127.0.0.1:81 
NameVirtualHost 127.0.0.1:81 
<VirtualHost 127.0.0.1:81> 
ServerName test.localhost 
DocumentRoot "d:\_projects\projectx" 
DirectoryIndex index.php 
</VirtualHost> 

windows\system32\drivers\etc\hosts我說:

127.0.0.1  test.localhost 

但現在http://test.localhost使我127.0.0.1:80

如何使其進入127.0.0.1:81

回答

3

就您的瀏覽器而言,http://test.localhosthttp://test.localhost:80

你需要的是一個Apache重定向...

<VirtualHost 127.0.0.1:80> 
ServerName test.localhost 

Redirect/http://test.localhost:81 
</VirtualHost> 
+0

嗯,我明白了。但是我已經在80端口上有其他東西了 - 所以我實際上不想重定向。儘管如此,你是一個技術上正確的人,所以你應該得到複選標記。 – Mathias