Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm trying to force SSL and non-SSL on certain pages of my site with redirects in the Lighttpd config file. I have redirects to SSL working fine:

$HTTP["host"] == "" {
     url.redirect = ( "(login|register/payment|resetpassword|account/password)" => "$1" )

And now I'm trying to go the other way around but I can't get the pattern to hit right (had a copy working fine under apache with .htaccess):

$HTTP["host"] == "" {
     url.redirect = ( "!(login|register/payment|resetpassword|account/password|images|css|javascript|minify/minify.php|states)" => "$1" )

I've tried many combinations but I usually end up in an endless redirect loop because the second matches all URLs when on the SSL port, or it doesn't trigger at all. Any suggestions?

share|improve this question
up vote 1 down vote accepted

Try using (?!: instead of !( for a negative match.

 url.redirect = ( "(?!:login|register/payment|resetpassword|account/password|images|css|javascript|minify/minify.php|states)" => "$1" )
share|improve this answer

Your Answer


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.