1: 用记事本打开C:/WINDOWS/system32/drivers/etc/hosts文件,配置如下:

127.0.0.1 localhost
127.0.0.1 phptest.com

2:因为我xampp是装在C盘的:用记事本打开C:\xampp\apache\conf\httpd.conf文件,找到Include conf/extra/httpd-vhosts.conf,确认前面没有加#.
2.1找到
[code]
<Directory />
AllowOverride none
Require all denied
</Directory>
[/code]
修改权限,变成:
[code]
<Directory />
Order deny,allow
Allow from all
</Directory>
[/code]

2.2在此文件末尾添加如下内容:
[code]
<Directory "D:/eclipse-php/workspace">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
[/code]

3:打开C:\xampp\apache\conf\extra\httpd-vhosts.conf,在此文件末尾添加如下内容:
[code]
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>

<VirtualHost *:80> //如果配置不同的端口号88,则需要在httpd.conf里面添加 Listen 88
DocumentRoot "D:/eclipse-php/workspace"
ServerName phptest.com
</VirtualHost>
[/code]

5:重启Apache服务即可。