一.绑定二级域名
httpd.conf 中需要打开mod_rewrite功
在httpd.conf 的最后,添加以下内容:
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/usr/local/etc/httpd/vhost.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
创建/usr/local/etc/httpd/vhost.map这个文件,内容为:
www.aaa.com /usr/local/www/aaa
bbb.aaa.com /usr/local/www/aaa/bbb
以后只需修改vhost.map文件,就可以添加二级域名了。
注意,如果你要配置windows下的绑定,这里RewriteCond ${vhost:%1} ^(/.*)$一定要修改,如果你的网站在D盘下,就修改成RewriteCond ${vhost:%1} ^(D:/.*)$,否则不起作用
二.绑定多个域名(转)
打开http.conf
1.ServerName 127.0.0.1 修改成ServerName 72.167.11.30
2.#NameVirtualHost * 修改成"NameVirtualHost 72.167.11.30"
3.在文件最后面有虚拟主机格式,
#<VirtualHost *>
# ServerAdmin [email]admin@minidx.com[/email]
# DocumentRoot /www/httpd/html/minidx.com
# ServerName minidx.com
# ErrorLog logs/minidx.com-error_log
# CustomLog logs/minidx.com-access_log common
#</VirtualHost>
简单的添加:
<VirtualHost 72.167.11.30>
DocumentRoot usr/local/www/
ServerName 72.167.11.30
</VirtualHost>
<VirtualHost 72.167.11.30>
DocumentRoot usr/local/www/minidx.com/
ServerName minidx.com
</VirtualHost>
<VirtualHost 72.167.11.30>
DocumentRoot usr/local/www/ntt.cc/
ServerName ntt.cc
</VirtualHost>