I could be wrong, but with your snippet I'd get domain.com redirected to www.domain.com, but also sub.domain.com redirected to www.sub.domain.com. Very possible I'm missing something here, though. :-) Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2924,2933#msg-2933