Actions
HowToRedirectHttpToHttps » History » Revision 24
« Previous |
Revision 24/33
(diff)
| Next »
gstrauss, 2020-05-20 05:25
How to redirect HTTP requests to HTTPS¶
Example 1 - redirect everything¶
lighttpd 1.4.50 or later may use:
$HTTP["scheme"] == "http" { url.redirect = ("" => "https://${url.authority}${url.path}${qsa}") }
Earlier versions of lighttpd 1.4.x may use:
$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") } }
Example 2 - specific url¶
lighttpd 1.4.50 or later may use:
$HTTP["scheme"] == "http" { url.redirect = ("^/phpmyadmin/" => "https://${url.authority}${url.path}${qsa}") }
Earlier versions of lighttpd 1.4.x may use:
$HTTP["scheme"] == "http" { $HTTP["host"] =~ ".*" { url.redirect = ("^/phpmyadmin/.*" => "https://%0$0") } }
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 over 4 years ago · 24 revisions