Report this

What is the reason for this report?

How to redirect www to non-www with static App?

Posted on October 7, 2025

Hi, I have a simple static website built with Astro. I’ve configured a domain with A record and www with CNAME. I want to redirect from www to non www domain (or vice versa), how can I achive this with Digital Ocean Static APP?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I usually handle this by keeping one as the primary domain (e.g. www.example.com) and then adding the other (example.com) as an alias in App → Settings → Domains & Certificates. From there you can enable the “redirect to primary domain” toggle — App Platform sends a 301 redirect automatically.

If you don’t see that toggle, drop a _redirects file into your Astro project before you deploy. For example:

/* https://www.example.com/:splat 301!

That forces all traffic to the www version.

No need for custom code or a separate server — just use either the alias redirect or the _redirects file.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.