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/ file.

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

! Be sure to change to suit your own domain name