I'm using lighttpd 1.4.28
Here is my redirect rule :
$HTTP["host"] =~ "^([^.]+\.[^.]+)$" {
url.redirect = ( "^/(.*)" => "http://www.%0/$1" )
}
It's supposed to redirect anydomain.anytld to www.anydomain.anytld and it works like a charm like I've written it here (of course, using %1 also works, since it refers to the parentheses.)
Yet, I'm baffled as to why it only works with the pair of parentheses you can see in the trigger regex.
%0 is supposed to catch the whole result, isn't it ? It doesn't even refer to a pair of parenthese, unlike %1, %2, etc. But if I remove those parentheses, like this :
$HTTP["host"] =~ "^[^.]+\.[^.]+$" {
url.redirect = ( "^/(.*)" => "http://www.%0/$1" )
}
I get this error when trying to restart lighttpd :
unreachable else condition 2012-10-17 11:34:10: (configfile.c.918) source: /etc/lighttpd/lighttpd.conf line: 173 pos: 14 parser failed somehow near here: (EOL)
Thanks !