zhufeng518 发表于 2017-1-10 09:10:12

apache下二级域名实现的精简配置

  在我最近给《商业网站开放服务平台》项目中,我需要给自动生成的网站设置一个二级域名,在Linux下配法比较简单,由于开发环境是windows,所以折腾了蛮久查了点资料才配起来了,在自己的博客中记录一下,我是这么做的:


[*]您的域名服务器提供商必须支持泛域名解析
[*]配置http-vhosts.conf,如下:
<VirtualHost *:80>
DocumentRoot "全路径"
ServerName faqee.com
ServerAlias *.faqee.com
RewriteLog         C:/rewrite.log
RewriteLogLevel   0
RewriteEngine      on
RewriteMap         lowercase int:tolower
RewriteMap         vhost txt:C:/vhost.map
RewriteCond      ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$
RewriteCond      ${vhost:%1} ^(C:/.*)$
RewriteRule      ^/(.*)$ %1/$1
ErrorDocument 404http://www.faqee.com/test/404.html
ErrorDocument 400http://www.faqee.com/test/404.html
ErrorDocument 500http://www.faqee.com/test/500.html
ErrorDocument 503http://www.faqee.com/test/500.html
</VirtualHost>
 
[*]打开apache的rewrite开关(去掉so注释)
[*]好了,试一下吧,现在一旦输入http://a.faqee.com。则就会documentroot为全路径下的a目录,简单吧!呵呵
  注:我使用的apache 2.2.8版本上测试通过
页: [1]
查看完整版本: apache下二级域名实现的精简配置