动态配置虚拟主机

动态配置虚拟主机

本文介绍了动态配置虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直升机!
我想prepare为将来使用mod_rewrite创建所有子一个动态的虚拟主机。所有子域名将被配置preTY很多相同的方式,所以我想使用动态VH配置。
我希望我的文档根目录为每个子域是/ home / user中/的public_html / SUBDOMAINNAME。

Helo!I would like to prepare a dynamic virtual host for all subdomains that will be created in future using mod_rewrite. All subdomains would be configured prety much same way, so i thought of using dynamic VH configuration.I want my document root for each subdomain to be /home/user/public_html/subdomainName.

我试过用下面的配置,但没有成功:

I've tried with following configuration, but had no success:

<VirtualHost xxx.xxx.xxx.xxx:80>
    # get the server name from the Host: header
    UseCanonicalName Off

    <Directory /home/user/public_html/>
    # ExecCGI is needed here because we can't force
    # CGI execution in the way that ScriptAlias does
      Options FollowSymLinks ExecCGI
    </Directory>

    RewriteEngine On

    # a ServerName derived from a Host: header may be any case at all
    RewriteMap lowercase int:tolower

    #rule that is suposed to set document root of virtual host!???
    RewriteRule ^([a-z-]+)\.domain\.com/?(.*) /home/user/public_html/$1/$2

</VirtualHost>

该规则或somethinh似乎是错的andit不适用。我从来没有使用动态VH合作过,所以我不知道在哪里我错了......

The rule or somethinh seems to be wrong andit doesn't apply. I've never worked with dynamic VH before so i have no idea where i'm wrong...

推荐答案

这是一个需要很多人在你面前了。所以这是一个Apache模块,它可以为你做的 mod_vhost_alias

This is a need a lot of people had before you. So there's an apache module which can do that for you mod_vhost_alias http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html

提供动态配置
  大规模虚拟主机

这篇关于动态配置虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:06