How can I redirect all pages but one to HTTPS on my lighttpd web server? I came up with the following, but it still redirects "/report.cgi" - I assume because the second redirect condition overrides the first:
# redirect HTTP
server.modules += ( "mod_redirect" )
$HTTP["scheme"] == "http" {
$HTTP["host"] =~ ".*" {
url.redirect = (
"^/report\.cgi$" => "http://%0$0",
"^/.*$" => "https://%0$0"
)
}
}
I need this since embedded devices should be able to contact my web server over HTTP.
Thanks to https://stackoverflow.com/a/3522147/3415618, I came up with the following solution:
# redirect HTTP
server.modules += ( "mod_redirect" )
$HTTP["scheme"] == "http" {
$HTTP["host"] =~ ".*" {
url.redirect = (
"^/(?!report.cgi).*" => "https://%0$0"
)
}
}