How can I enable www subdomain


#1

Hi guys, I want to know how can I enable “www” (https://www.mydomain.com), but keep mydomain.com as primary hostname. I mean, redirecting from “www” to non-“www”, using let’s encrypt.

I found a guide about install nginx after to install discourse from docker, but I’m very noobie, so can anyone help me and explain me all steps. My forum is empty so no problem to reinstall everything if it’s necessary.

ps. Ubuntu 18, digital ocean vps droplet.


(Jeff Atwood) #3

I’m pretty sure that wasn’t what he was asking at all @pfaffman … he was asking “how do I automatically redirect visitors to the non-www version of my domain”.

example.com
www.example.com

This is most easily done via the DNS controls where you purchased your domain name from. If your DNS provider doesn’t support redirection, you’re stuck implementing redirects in your webserver.


(Michael - DiscourseHosting.com) #4

We offer a free service to do it the other way around (and that page also gives some reasons why that is a better idea).


(Jay Pfaffman) #5

If he points both domains to his Discourse server and he has https on his site he’s fine as long as people hit the http version. Then it’ll do the redirect to https://example.com as desired.

If what he wants is also to have https://www.example.com to redirect to the bare domain, then the instructions I link to provide at least a hint of how to accomplish that. (I’m pretty sure that I did that recently.)


(Jeff Atwood) #6

No, that topic is about multisite and multiple domains hosted on the same machine, that is

example.com
foo.org
bar.net


#7

hi again, well, I just created an A record “www” pointing to my droplet’s IP, and apparently it worked fine,

can you give me a feedback if it’s working?

Basically I want force www to non-www, and https: clic here


(Jay Pfaffman) #8

http://www.kamehouse.net/ – works as you wish
https://www.kamehouse.net/ – is a certificate error

It’s not that likely that someone will stick https in front of the www, so you’re probably in good shape.


#9

edit, can I get a certificate from cerbot just for www w/o install discourse again?


(Stephen) #10

Why not just set up a redirect? There’s no value in having your instance published under two discrete fqdn.

Get your domain off of digitaloceans DNS, and use your domain registrar’s tools to redirect any additional subdomains to the main URL. This doesn’t need to touch your discourse install at all.