代码之家  ›  专栏  ›  技术社区  ›  naiquevin

关于在apache上设置伪/伪子域的帮助

  •  0
  • naiquevin  · 技术社区  · 15 年前

    我想要达到的是-

    yourname.myapp.tld

    这可以通过做类似的事情来实现吗-

    当访问者键入任何子域(anything.myapp.tld)时,他就可以访问myapp。在index.php文件中,我将分解$\u服务器['HTTP\u HOST']以获得将存储在会话中的子域,然后作为该用户的标识符。理想情况下,我不想创建任何vhost或向hosts文件添加许多行。仅用一个vhost就可以实现这一点吗?

    这是不是可以用mod rewrite什么的?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Prix Winteroo    15 年前

    在dns上有这样一个条目(在ubuntu上安装dns https://help.ubuntu.com/10.04/serverguide/C/dns.html ):

    ; wildcard subdomains are all directed to this IP
    ;  of course this should be the IP of your web server
    *.domain.tld.      IN  A    1.2.3.4
    

    <VirtualHost 111.22.33.55>
        DocumentRoot /www/subdomain
        ServerName www.domain.tld
        ServerAlias *.domain.tld
    </VirtualHost>
    

    之后发生的事情是everything.domain.tld将转到主文件夹,这样您就可以使用index.php将其重定向到正确的位置,甚至可以使用mod\u rewrite将其重定向到htaccess。