Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
    • ...
share|improve this question
up vote 2 down vote accepted

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" )
  }
}
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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