Adding www. to Domain

I have set up my Discourse community with Digital Ocean, but the domain name is “naked”, at just https://example.com. I would like to add the www., but not quite sure what I am doing when it comes to DNS settings!

At the moment I have an ‘A’ record pointing to the IP and a ‘CNAME’ record with www. pointing to this. Is it as simple as changing the www. to an ‘A’ record and ditching the CNAME? Or perhaps I have them both as ‘A’ records? Or perhaps there is a simple setting in Discourse itself which selects how the domain will appear?

It is funny, I have a normal wix site which appears to be the same configuration with a naked A record and www. CNAME which shows up as www. in the browser - so I am not sure what it is that makes it show like that.

I promise I have tried to further educate myself on DNS, but am totally confused!

Any help on how to add the www. is much appreciated! :slight_smile:

2 Likes

First off, create a DNS record like:

TYPE:             CNAME
HOST:             WWW
POINTS TO:        @

Then follow this guide:

3 Likes

Thank you very much for this - I have successfully got it working at the www. by re-running the discourse-setup script as in your article, but now the naked domain no longer works! Is there any way I can make the naked domain work as well - or at least automatically fill in the www.?

So I now have A record linking naked domain to IP address
CNAME record linking www to naked domain

Many thanks!

1 Like

The easy way is forcewww.com. Harder is Setting up Let’s Encrypt with Multiple Domains.

2 Likes

Thank you for this - I have read through both options, but just wondered, why could I not just use a simple 301 redirect to redirect from naked domain to www.? Is this worth a try or am I breaking DNS laws?

2 Likes

Both of those methods provide a letsencrypt certificate for the second (sub)domain. Adding the extra info to your app.yml covers both domain addresses in the same certificate, and forcewww.com has some special magic that does it on the fly so you don’t have to worry about it:

2 Likes

O.K sounds as if I should just use forcewww. Can I just confirm (sorry I am very out of my depth) - they are asking me to set up the www as an A record to my server IP, and the naked domain as an A record to the IP address they give? So no CNAMES?

What I have now:
A record pointing naked domain to server IP
CNAME record pointing www to naked domain

Proposed change using ForceWWW
A record pointing naked domain to forcewww IP
A record pointing www to my server IP

1 Like

I think that’s how it works. :+1:

1 Like

Thanks! I have set it up - not working yet (typing in naked domain) but it may take a few hours to take effect so will wait and see!

2 Likes

Yay I think it works! Thank you very much for all your help!

3 Likes

Unfortunately - this has somehow broken the emailing system - the site is not sending any emails through mailgun. Might this be because of the forcewww - as the host is now through their server? Or do I need to update mailgun to say www? Lord give me strength.

1 Like

You need to change the DISCOURSE_NOTIFICATION_EMAIL to noreply@baredomain.com. I’d edit the yml and destroy and start the container.

1 Like

Thanks - I reset the smtp password and then ran the discourse setup script again and that seems to have done the job! I don’t know how or why, but it works so I will just not touch anything!

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.