if ($host != $server_name) {

      rewrite ^/(.*)$ http://$server_name/$1 permanent;

 }