Redirecting www To non-www And Vice Versa
Note: This post was written in 2012. The .htaccess rules below still work on Apache servers, but modern setups (NGINX, Caddy, Apache 2.4 with virtual hosts) handle redirects differently. The rules also use http:// — update them to https:// for any SSL-enabled site. Every domain can be accessed through two different URLs. Take example.com — it's reachable as both example.com and www.example.com. The same applies to subdomains. From a user's point of view this doesn't matter much, but from an SEO standpoint it's a problem. Having the same content available on two different URLs can be flagged as duplicate content and hurt your search rankings.