Report this

What is the reason for this report?

App Platform: How can I redirect non-www to www?

Posted on December 29, 2020

Hello!

Currently, I have the following setup:

A static site that is served on www.example.com/ and a Node.js app that runs on www.example.com/server. Both are created via the App Platform.

Is it possible to redirect non-www HTTPS traffic (https://example.com/) to www (https:/www.example.com/)?

Or do I have to use a dockerfile and fiddle around with nginx to achieve this?



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.

Hello, if you require it, App Platform can support root domains. Provided your DNS service allows for CNAME flattening or using an ANAME or ALIAS record, you can point the appropriate record to the actual app url (ex. my-do-app-a1bcd.ondigitalocean.app.) From there everything should work for your root domain “example.com”, and you could create a CNAME record for “www” host to point to your root.

If you really want to do what you are asking I believe you may be able to achieve it using URL Redirect Record or an ALIAS record if your DNS service provides them. For example set the redirect or ALIAS record to redirect / point the root domain “@” to www.example.com.

This comment has been deleted

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.