I am using nginx on Rackspace cloud following a tutorial and having searched the net and so far can\'t get this sorted.
I want www.mysite.com to go to mysite.com as
If you don't want to hardcode the domain name, you can use this redirect block. The domain without the leading www is saved as variable $domain which can be reused in the redirect statement.
server {
...
# Redirect www to non-www
if ( $host ~ ^www\.(?.+) ) {
rewrite ^/(.*)$ $scheme://$domain/$1;
}
}
REF: Redirecting a subdomain with a regular expression in nginx