Skip to main content
Redirect to WWW

How to redirect all traffic from a root domain to the `www` subdomain, e.g. example.com -> www.example.com

Drago Crnjac avatar
Written by Drago Crnjac
Updated over 7 months ago

This guide outlines how to enable the WWW Redirect feature on SaaS Custom Domains, ensuring that traffic from your root domain (e.g., example.com) automatically forwards to its WWW version (e.g., www.example.com). This feature not only simplifies certificate management but also improves your site's SEO by avoiding duplicate content issues.

Benefits of WWW Redirect

  • Consistent URL Structure: Maintains a uniform URL format across your site, which can enhance user experience.

  • SEO Enhancement: Reduces the risk of penalization for duplicate content by search engines, which can improve your site's search engine rankings.

  • Simplified SSL/TLS Certificate Management: Automatically covers both the root and WWW versions of your domain, ensuring secure access through HTTPS.

How to Enable WWW Redirect in the UI

When creating the custom domain manually, simply check the Redirect to www checkbox.

How to Enable WWW Redirect in the API

When creating the custom domain through the API, set the redirect_to_www property to true.

Important Notes

  • Handling of WWW Subdomains: If you create a WWW domain (e.g., www.example.com), enabling WWW Redirect will not lead to recursive redirects (like www.www.example.com). Instead, it ensures that example.com redirects to www.example.com.

  • Handling non-www Subdomains: Redirecting to www only works for root domains. If you try to enable the www redirect for subdomains the request will fail.
    e.g. trying to create test.example.com with redirect_to_www: true will fail with 400 Bad Request.

  • DNS Configuration: Upon enabling the WWW Redirect, Automated DNS Instructions Emails will contain additional instructions to ensure proper functionality of the redirect.

  • Redirect HTTP Status Code: We use 301 Moved Permanently status code when redirecting to www.

  • Plan Thresholds: Custom Domain with WWW Redirect counts as two domains towards your plan. This is because we have to issue two TLS certificates for this type of domain β€” one for the root domain, and one for the www subdomain.

That's it! You have learned how to enable redirecting to the WWW subdomain.
​
Until next time, keep building!


Need more help? Reach out via the Intercom chat widget and we'll be right with you!

Did this answer your question?