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

如何使用lighttpd中的GET参数将子域指向特定文件?

  •  0
  • theAdam  · 技术社区  · 12 年前

    我想要一个 lighttpd 服务器在访问者通过子域时将其重定向/重写到特定页面。这是一个例子。

    网站启动和运行:

    www.example.com
    

    所述网站的目标页面:

    www.example.com/subpage
    

    要指向目标页的子域:

    www.sub.example.com
    

    因此,当访问者键入: www.sub.example.com 我希望浏览器显示 www.example.com/subpage

    这可能吗?如果是的话,你能给我解释一下吗?

    我试过摆弄vhost.conf文件,但没有用。以下是我尝试的:

    $HTTP["host"] =~ "sub\.example\.com" {
    server.document-root = "/var/www/example.com/www/"
    server.error-handler-404 = "/index.php" 
    
    index-file.names   = ( "/subpage" )
    
    }
    

    感谢您提前提出任何建议!

    1 回复  |  直到 12 年前
        1
  •  0
  •   Osmaan Shah    12 年前

    一种方法是使用url.redirect功能,将www.sub.example.com重定向到www.example.com/subpage

    $HTTP["host"] =~ "example.com" {
         $HTTP["host"] =~ "www.sub.example.com" {
              url.redirect = (
                 "(.*)" => "http://www.example.com/subpage"
              )
         }
         else $HTTP["host"] =~ "www.example.com" {
             server.document-root = "/var/www/example.com/www/"
             server.error-handler-404 = "/index.php"
         }
     }