lighttpd-将所有内容重定向到https

lighttpd-将所有内容重定向到https

我曾尝试使用此示例维基页面-

$HTTP["scheme"] == "http" {
    # capture vhost name with regex conditiona -> %0 in redirect pattern
    # must be the most inner block to the redirect rule
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
    }
}

但是当我输入这个网址时-

http://www.domain.co.il/index.php?shop=amazon

我被重定向到

https://index.php/index.php?shop=amazon

问题是什么?

答案1

删除后一切正常 -

url.rewrite-once = ( "^/min/([a-z]=.*)" => "/min/index.php?$1",
        "^(.*)\.(jpg|gif|woff|tff|png|js|css|html|htm|txt)(.*)$" => "$0",
        "^/question2answer/(.+)$" => "/question2answer/index.php?qa-rewrite=$1",
       "^/$" => "/index.php"
     )

答案2

这可能不是最优雅的方式,但对我们来说很有效。明确捕获正则表达式匹配。(注意:也许应该是"https://%1$1"

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

相关内容