1 2 3 4 |
#非www跳转到www的正则 $HTTP["host"] =~ "^([^.]*.[^.]*)$" { url.redirect = ( "^/(.*)" => "http://www.%1/$1" ) } |
——正则表达式渣渣的个人备忘
如果你希望加一点特殊的域名允许他非www不跳转:
1 2 3 4 |
#非www跳转到www的正则 $HTTP["host"] =~ "^((?!hiwbb)[^.]*.[^.]*)$" { url.redirect = ( "^/(.*)" => "http://www.%1/$1" ) } |
反过来操作?lighttpd内有示范:
1 2 3 4 5 6 |
## ## both rewrite/redirect support back reference to regex conditional using %n ## #$HTTP["host"] =~ "^www\.(.*)" { # url.redirect = ( "^/(.*)" => "http://%1/$1" ) #} |