1. 安装mod_rewrite模块来实现;
2. 使用基于名字的虚拟主机配置,例如:
NameVirtualHost *
<VirtualHost *>
ServerName www.foo.net
ServerAlias foo.com
Redirect permanent / http://www.foo.com/
</VirtualHost>
<VirtualHost *>
ServerName www.foo.com
DocumentRoot /var/www/htdocs
</VirtualHost>