Redirecting the www version of your domain automatically (or vice versa)

Surge automatically redirects the www version of your domain to your root domain, including for custom domains. This improves your project for both visitors and search engines:

  • Visitors that add the www in-front of your domain name will automatically be redirected to the correct location.
  • Search engine robots that are crawling your site prefer when you have a single site at the www domain, or at the root of the domain, rather than both.

In short, when you publish your site:

surge --domain example.com

…then www.example.com will automatically redirect to example.com.

Using the www version of your domain

If you’d prefer to use www.example.com as the default version of your site, you may explicitly publish to that domain instead:

surge --domain www.example.com

…now, http://example.com will automatically redirect to example.com.

If you have a choice, especially if this is a new project, we reccomend you leave the default options alone and allow the www version to redirect to the root version of your domain.