Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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"] == "www.site.com:80" {
     url.redirect = ( "(login|register/payment|resetpassword|account/password)" => "https://www.site.com/$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"] == "www.site.com:443" {
     url.redirect = ( "!(login|register/payment|resetpassword|account/password|images|css|javascript|minify/minify.php|states)" => "http://www.site.com/$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
add comment

1 Answer

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)" => "http://www.site.com/$1" )
share|improve this answer
add comment

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.