Lighttpd domain redirection

Posted by HTF on Server Fault See other posts from Server Fault or by HTF
Published on 2012-09-22T08:36:05Z Indexed on 2012/09/22 9:39 UTC
Read the original article Hit count: 188

Filed under:

I would like to redirect domains on HTTP/HTTPS:

http://old.com -> https://new.com
https://old.com -> https://new.com

I have to specify the SSL key/certificate for the old domain but I'm not sure where I have to place these directives:

$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/pki/tls/private/new.com.pem"
ssl.ca-file = "/etc/pki/tls/certs/new.com.crt"
}

$SERVER["socket"] == ":80" {
  $HTTP["host"] =~ "old.com|new.com" {
    url.redirect = ( "^/(.*)" => "https://new.com:443/$1" )
  }
}

I was trying to add the code below but Lighttpd reports configuration errors:

$SERVER["socket"] == ":443" {
$HTTP["host"] =~ "old.com" {
url.redirect = ( "^/(.*)" => "https://new.com:443/$1" )
   }
ssl.engine = "enable"
ssl.pemfile = "/etc/pki/tls/private/old.com.pem"
ssl.ca-file = "/etc/pki/tls/certs/old.com.crt"

}

© Server Fault or respective owner

Related posts about lighttpd