将子目录重定向到 lighttpd 中的另一个域

时间:2021-07-21 23:22:29

标签: redirect lighttpd

我正在尝试将子目录重定向到不同的域,最好是 https。我有一些重定向规则可以将 http 转发到 https 及其工作,但我希望一个特定的子目录转发到另一个域。它应该将 example.com/subdir/whatever 转发到 newdomain.com/whatever

  $HTTP["host"] =~ "example.com" {
    accesslog.filename         = "/var/log/lighttpd/example.com/access.log"
    url.redirect = ( "^/(.*)" => "https://example.com/$1" )
    server.name                 = "example.com"
  }
}

1 个答案:

答案 0 :(得分:0)

您是否尝试过阅读文档? https://wiki.lighttpd.net/Docs_ModRedirect

url.redirect = (
  "^/subdir/whatever/(.*)" => "https://newdomain.com/whatever/$1",
  "^/(.*)" => "https://example.com/$1"
)