Question

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

Posted December 29, 2020 1.5k views
Node.jsDjangoDigitalOcean App Platform

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?

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.

×
Submit an Answer
1 answer

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.