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!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.