I have used this one:
$HTTP["scheme"] == "https" {
$HTTP["host"] =~ "example.com" {
url.redirect = ( "^/(.*)" => "http://www.example.com/$1" )
}
}
But be careful, some browser keep in mind that a website use https
. So it will always try to access the https
version no matter the redirect that send the webserver. I have tried this case and Firefox / Chrome told me that my website goes into an infite redirect loop. But when I curl my website on https
, I got a 301 to http
. And on http
a 200.
So it's hard to test ...
For your second question, it's in the doc:
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.