2

Trying to understand how to make the redirect to redirect all http traffic to https on lighttpd webserver using 301.

For instance http://www.example.com should redirect to https://www.example.com and it should work for all sub pages as it's basically rewrite to https.

kasperd
  • 30,455
  • 17
  • 76
  • 124
Andreas
  • 161
  • 1
  • 6
  • Possible duplicate of [Remove "www" and redirect to "https" with nginx](http://serverfault.com/questions/258378/remove-www-and-redirect-to-https-with-nginx) – Roman Mar 02 '16 at 12:13
  • @Roman That question is about nginx, this question is not. – kasperd Mar 02 '16 at 15:52
  • @kasperd: Thanks for highlighting, retracted vote accordingly. – Roman Mar 03 '16 at 09:06

2 Answers2

4

After some additional search I found a solution. Added to lighttpd.conf restarted and everything works as expected.

$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")
    }
}
Andreas
  • 161
  • 1
  • 6
0

I think you did a typo because you wrote from http://mydomain should redirect to http://mydomain, I think you mean to https://mydomain.

I hope this will help you. I have used this Information for my NGINX Webserver:

HSTS on Lightpttd - Turtorial

SystemCookie
  • 169
  • 1
  • 14