if ($host !~* "^\w{2,3}\.") { rewrite ^(.*)$ http://www.$host$1 permanent; }