apache中ServerAlias绑定多个域名到同一空间

发布时间:2020-04-18编辑:脚本学堂
apache中ServerAlias绑定多个域名到同一空间

apache中可以设置多个别名,中间用空格分开:Serveralias jbxue.net en.jbxue.net 这些域名访问的同一个站点的内容。

复制代码 代码如下:

<VirtualHost *:80>
    ServerAdmin  admin@jbxue.met
    DocumentRoot "/usr/local/web/apache/htdocs/"
    ServerName #默认域名
    ServerAlias jbxue.net en.jbxue.net #差别 域名用空格离隔
    <proxy balancer://cluster>
        BalancerMember ajp://127.0.0.1:8010/ loadfactor=1 route=jvm8010
        BalancerMember ajp://127.0.0.1:8011/ loadfactor=1 route=jvm8011
    </proxy>
    ProxyPass / balancer://cluster/ stickysession=JSESSIONID nofailover=On lbmethod=byrequests timeout=5 maxattempts=5
    ProxyPassReverse / balancer://cluster/

    ErrorLog "logs/www.jbxue.net-error_log"
    CustomLog "logs/www.jbxue.net-access_log" common
</VirtualHost>

泛域名设置:

复制代码 代码如下:

<VirtualHost *:80>
    ServerAdmin
    DocumentRoot "/usr/local/web/apache/htdocs/"
    ServerName #默认域名
    ServerAlias *.jbxue.net #用*表示泛域名,假如要设置三级泛域名,可以这样 :*.my.jbxue.net
    <proxy balancer://cluster>
        BalancerMember ajp://127.0.0.1:8010/ loadfactor=1 route=jvm8010
        BalancerMember ajp://127.0.0.1:8011/ loadfactor=1 route=jvm8011
    </proxy>
    ProxyPass / balancer://cluster/ stickysession=JSESSIONID nofailover=On lbmethod=byrequests timeout=5 maxattempts=5
    ProxyPassReverse / balancer://cluster/

    ErrorLog "logs/www.jb200.com-error_log"
    CustomLog "logs/www.jb200.com-access_log" common
</VirtualHost>