第一步:
修改C:WINDOWSsystem32driversetchosts文件
127.0.0.1 localhost127.0.0.2 ci
第二步,修改apache配置文件,在配置文件的最后面,插入下面设置
<VirtualHost 127.0.0.1:80>DocumentRoot "D:/wamp/www/localhost"
ServerName 127.0.0.1:80
</Virtualhost>
<Directory "D:/wamp/www/localhost">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<VirtualHost 127.0.0.2:80>
DocumentRoot "D:/wamp/www/ci"
ServerName 127.0.0.2:80
</Virtualhost>
<Directory "D:/wamp/www/ci">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.2
</Directory>
第三步:重启apache
enjoy!
如果需要多设置几个域名,只需要在hosts下增加一条IP,再把下面的apache配置复制一份,并修改五个地方:
//第一处,这里的IP,要在hosts存在
<VirtualHost 127.0.0.2:80>
//第二处,目录
DocumentRoot "D:/wamp/www/ci"
//第三处,IP,跟第一处要一样
ServerName 127.0.0.2:80
</Virtualhost>
//第四处,目录,跟第二处一样
<Directory "D:/wamp/www/ci">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
//第五处,IP,与一,三处一致,但不包括端口号。
Allow from 127.0.0.2
</Directory>