Marc
Marc

Reputation: 377

How do I set up a HTTP to HTTPS redirection for a specific domain in lighttpd?

I would like to redirect specific domains from http to the corresponding https address in lighttpd. I tried out the tutorial on the lighttpd page but there it is not written for a specific domain. This is what I want:

$HTTP["host"] =~ "secure.example.com" {
     server.document-root = "/var/www/secure.example.com"
     // IF NOT SSL, REDIRECT TO SSL
}

Thanks for your help.

Upvotes: 4

Views: 1674

Answers (1)

Colin Hebert
Colin Hebert

Reputation: 93187

You can use port detection to be sure that your user come from an HTTP URL

$SERVER["socket"] == ":80" {
  $HTTP["host"] =~ "example.org" {
    url.redirect = ( "^/(.*)" => "https://example.org/$1" )
    server.name                 = "example.org" 
  }
}

Resources :

Upvotes: 3

Related Questions