首页 > 解决方案 > 将子目录重定向到 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"
  }
}

标签: redirectlighttpd

解决方案


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

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

推荐阅读