I would like to redirect a specific section of a website from HTTP:// to HTTPS:// using Lighttpd.

I've been looking at this Lighttpd wiki entry, but the examples don't work the way I want.

I have two requirements:

  1. No specific domain should be specified in the URL redirection configuration.
    • NOT something like this: "^/(.*)" => "https://www.example.com/secure/"
  2. The redirection should also be applied to sub-items of the location, i.e.
    • http:// hostname/secure => https:// hostname/secure
    • http:// hostname/secure/subdir/file.ext => https:// hostname/secure/file.ext
    • ...

Actually, one of their examples is a near-perfect match to your requirements - just needs tweaked to only work in the secure directory:

$HTTP["url"] =~ "^/secure/" {
  $HTTP["host"] =~ "(.*)" {
    url.redirect = ( "^/(.*)" => "https://%1/$1" )
  • Thanks you, that seems to work perfectly. Of course I needed to wrap around it $SERVER["socket"] == ":80" { ... }. – johndir Nov 28 '11 at 22:09
  • Great, it was exactly what I was looking for. – 0xC0000022L Jan 6 '12 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.