Actions
HowToRedirectHttpToHttps » History » Revision 22
« Previous |
Revision 22/33
(diff)
| Next »
gstrauss, 2018-10-15 23:07
How to redirect HTTP requests to HTTPS¶
Since 1.4.19 the following should work. For older versions check the history of this page... or just update, srsly.
Example 1 - redirect everything¶
$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") } }
lighttpd 1.4.50 or later may also use:
$HTTP["scheme"] == "http" { url.redirect = ("" => "https://${authority}${path}${qsa}") }
Example 2 - specific url¶
$HTTP["scheme"] == "http" { $HTTP["host"] =~ ".*" { url.redirect = ("^/phpmyadmin/.*" => "https://%0$0") } }
lighttpd 1.4.50 or later may also use:
$HTTP["scheme"] == "http" { url.redirect = ("^/phpmyadmin/" => "https://${authority}${path}${qsa}") }
Example 3 - only for specific vhost and url¶
$HTTP["scheme"] == "http" { $HTTP["host"] == "sth.example.com" { url.redirect = ("^/phpmyadmin/.*" => "https://sth.example.com$0") } }
Further stuff¶
Also works the other way round (https -> http) with if $HTTP["scheme"] == "https"
Updated by gstrauss about 6 years ago · 22 revisions