0

I am using Lighttpd with a snipped i've found on the net. How to redirect all subdomains of a given domain to https without touching other domains or subdomains of domains?

Currently i am doing this on the needed subdomains:

$SERVER["socket"] == ":80" {
    $HTTP["host"] =~ "^sub\.(.*)" {
            url.redirect = ( "^/(.*)" => "https://sub.%1/$1" )
    }
}

I would love to have it the over way around. Is it possible? Can anyone tell me how?

rugar
  • 123
  • 3

1 Answers1

0

If I understand right, you'd want to take, say, example.com and redirect not for example.com, but for all of its subdomains?

This should do it:

$HTTP["host"] =~ "^(.*\.example\.com)$" {
  url.redirect = ( "^/(.*)" => "https://%1/$1" )
}
Shane Madden
  • 112,982
  • 12
  • 174
  • 248