在 lighttpd 中將 HTTPS 請求重定向到 http
我正在執行一個安裝了 SSL 證書的 lighttpd 伺服器。由於某些原因,我想轉發所有 https://www. 請求 http://www.
我的 lighttpd 程式碼如下所示:
$SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "/path/to/pem/file" ssl.ca-file = "/path/to/ca/file" HTTP["host"] =~ "^www\.(.*)$" { url.redirect = ("^/(.*)" => "http://www.%1$1") } }
你能在這裡指出問題嗎。另一件事, %1 和 $1 有什麼區別?
我用過這個:
$HTTP["scheme"] == "https" { $HTTP["host"] =~ "example.com" { url.redirect = ( "^/(.*)" => "http://www.example.com/$1" ) } }
但要小心,有些瀏覽器會記住網站使用
https
.https
因此,無論發送網路伺服器的重定向如何,它都會嘗試訪問該版本。我已經嘗試過這種情況,Firefox / Chrome 告訴我我的網站進入了無限重定向循環。但是當我捲曲我的網站時https
,我得到了 301 到http
. 並在http
200 上。所以很難測試…
對於您的第二個問題,它在文件中:
Note that the “%1” in the url.redirect target refers to the parenthesized subexpression in the conditional regexp (.*). It does not necessarily have the meaning that “%1” would have in evhost.path-pattern (where it would mean ’top-level domain’). If url.redirect is specified within a regex conditional, % patterns are replaced by the corresponding groups from the condition regex. %1 is replaced with the first subexpression, %2 with the second, etc. %0 is replaced by the entire substring matching the regexp. See above and below for examples using % patterns.