Lucas de Faria
Lucas de Faria

Reputation: 23

HTTPS Redirection not working in Lightppd

I need to redirect https://www.mysite.com/folder/subfolder to https://www.mysite.com/folder/ in lighttpd. I've tried the following:

$HTTP["host"] =~ "https://www.mysite.com/folder/folder" {
  url.redirect = (
    ".*" => "https://www.mysite.com/folder/" 
  )
}

but it did not work.

Can anyone please tell me the correct syntax in Lighttpd?

Thanks.

Upvotes: 2

Views: 1314

Answers (1)

Ian
Ian

Reputation: 7558

This might be because the mod_redirect module isn't available (it's typically disabled by default).

  1. If you're on a UNIX platform open modules.conf, probably in /etc/lighttpd (on Windows the settings are in lighttpd.conf).
  2. Find server.modules and uncomment mod_redirect
  3. Then add a redirect rule to your lighttpd.conf. I've implemented my rule in a slightly different way to you - I redirect all http:// requests for a given host to their https:// equivalent.

modules.conf

server.modules = (   
    "mod_access",  
    "mod_proxy",
    "mod_accesslog",  
#   "mod_alias",  
#   "mod_auth",  
#   "mod_evasive",  
    "mod_redirect",  
    "mod_rewrite"  
#   "mod_setenv",  
#   "mod_usertrack",  
) 

lightttpd.conf

$HTTP["scheme"] == "http" {
    $HTTP["host"] =~ "^subdomain.server.com" {
        url.redirect = (".*" => "https://%0$0")
    }
}

Upvotes: 2

Related Questions