Lighttpd:将特定位置和子位置从HTTPredirect到HTTPS(不使用域名)

我想redirect网站的特定部分从HTTP://到HTTPS://使用Lighttpd。

我一直在看这个Lighttpd维基条目 ,但是这些例子并不按照我想要的方式工作。

我有两个要求:

  1. 在URLredirectconfiguration中不应该指定特定的域。
    • 不是这样的: "^/(.*)" => "https://www.example.com/secure/"
  2. redirect也应该应用到位置的子项目,即
    • http://主机名/安全=> https://主机名/安全
    • http:// hostname / secure / subdir / file.ext => https:// hostname / secure / file.ext

实际上,他们的例子之一是与您的要求几乎完美匹配 – 只需要调整,只能在安全的目录中工作:

 $HTTP["url"] =~ "^/secure/" { $HTTP["host"] =~ "(.*)" { url.redirect = ( "^/(.*)" => "https://%1/$1" ) } }