【问题标题】:Apache2 wildcard subdomainsApache2 通配符子域
【发布时间】:2011-07-28 04:42:38
【问题描述】:

我有一个问题想看看是否有可能,因为我的搜索结果是空的,或者同一个博客讲述的内容完全不同......

基本上,我已将 *.mydomain.com 的 A 记录添加到我的 IP...好吧,简单的事情结束了。

现在我创建了一个类似的 VirtualHost:

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias *.mydomain.com
    DocumentRoot /home/sites/mydomain.com/htdocs
</VirtualHost>

现在,如果我希望它们都指向 index.php 页面,以上内容就可以了。但是我想要一个更复杂的 VirtualHost...

链接看起来像这样:

http://someusername.mydomain.com/public/repositoryname

这将指向类似以下内容:

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias *.mydomain.com

    <Location /home/svn/{someusername}/{public}/{repositoryname}>
        #Some more code in here...
    </Location>
</VirtualHost>

显然是位置变量:

{someusername} - Will be what the subdomain is
{public} - Will be the first GET parameter from the url query string
{repositoryname} - Will be the second GET paramter from the url query string

现在我知道这可能会使 Apache WildCards 达到极限,但我需要知道这是否可以实现。

非常感谢, 肖恩

【问题讨论】:

    标签: apache2 virtualhost


    【解决方案1】:

    我发现了如何通过启用 mod_perl 并编写自定义 perl 脚本来实现这一点。任何有类似问题的人肯定会考虑使用 Perl 来解决这个问题!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-03
      • 2020-08-23
      • 2012-01-20
      • 2016-07-24
      • 2010-09-09
      • 2016-12-08
      • 2021-05-27
      • 2011-08-16
      相关资源
      最近更新 更多