具有多个 ServerAlias 的 Apache2 动态虚拟主机

编程入门 行业动态 更新时间:2024-10-26 06:31:36
本文介绍了具有多个 ServerAlias 的 Apache2 动态虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置动态虚拟主机,但遇到了一些麻烦.它不允许我设置多个 ServerAlias.

I am trying to set up a dynamic vHost, but have run into some trouble. It will not allow me to set multiple ServerAlias.

<VirtualHost *:80>
        ServerAlias *
        ServerAdmin michael.ian.curry@gmail
        VirtualDocumentRoot /var/www/%1/production/html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        LogLevel warn
</VirtualHost>

上述虚拟主机仅适用于",我需要它才能用于www."和*"我认为将 ServerAlias 设置为可以修复它,但它不起作用.

The above vHost only works for '' i need it to work for 'www.' and '*' I assumed that setting the ServerAlias to would fix it, but it is not working.

ServerAlias * www.*

如果您有任何见解,请回复

If you have any insight, please respond

--迈克尔库里

==编辑 1==

例如 redcrusher 和 www.redcrusher

Example redcrusher and www.redcrusher

==编辑 2==

下面的代码也不起作用

ServerAlias www.* *

推荐答案

想通了!

'www.*' 必须在 '*' 之前执行 这是因为 ServerAlias 正在设置一个动态域,并且必须在较小"别名存在之前存在.

'www.*' must execute before '*' This is because ServerAlias is setting a dynamic domain and must exist before a "smaller" alias exists.

示例:'www.*'、'dev.*'、'asdf.*' THEN '*'

Example: 'www.*', 'dev.*', 'asdf.*' THEN '*'

虚拟主机文件 [production.conf]:

vHost File [production.conf]:

<VirtualHost *:80>
    ServerAlias www.*
    VirtualDocumentRoot /var/www/%2/production/html
    ServerAdmin michael.ian.curry@gmail
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    LogLevel warn
</VirtualHost>

<VirtualHost *:80>
    ServerAlias *
    VirtualDocumentRoot /var/www/%1/production/html
    ServerAdmin michael.ian.curry@gmail
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    LogLevel warn
</VirtualHost>

我希望这可以帮助其他遇到此问题的人!

I hope this helps anyone else that is having this problem!

--迈克尔库里

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

更多推荐

[db:关键词]

本文发布于:2023-03-26 22:54:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/670337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   虚拟主机   动态   ServerAlias

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!