How can I rewrite nginx to redirect non-www to www and vice versa?
I have tried the following by adding it in the nginx directives without luck.
non-www to www:
rewrite ^(.*) http://www.example.com$1 permanent;
www to non-www:
rewrite ^(.*) http://example.com$1 permanent;