Adding rewrite for www to non-www

The easiest way to add an Nginx rewrite to redirect your traffic from www to non-www is to add the following Nginx code snippet to your domain's ___general/example.com.conf file.

set $redirect "0";
if ($host ~* "^www\.example\.com$")  { set $redirect "go"; }
if ($redirect = "go") {
  rewrite ^(.*)$ $my_http://example.com$1 permanent;
}

! Be sure to change example.com to suit your own domain name