# Making 'www' work with Discourse

**URL:** https://meta.discourse.org/t/making-www-work-with-discourse/150785
**Category:** Support
**Created:** [May 8, 2020, 4:23am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785 "2020-05-08T04:23:38Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Erik\_Manger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erik_manger/32/179399_2.png) [@Erik\_Manger](https://meta.discourse.org/u/Erik_Manger)
#### Post date: [May 8, 2020, 4:23am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/1 "2020-05-08T04:23:38Z")

</div>

Hi there, I would like to make sure the www subdomain redirects the users to the actual Discourse install. I feel like this needs to be the case to ensure I don’t lose visitors. Most people don’t leave out the ‘www’ when visiting websites.

---

<div class="post-metadata">

### Author: ![007](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/007/32/175794_2.png) [@007](https://meta.discourse.org/u/007)
#### Post date: [May 8, 2020, 4:29am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/2 "2020-05-08T04:29:21Z")

</div>

You need to add an A record in your DNS settings at your registrar for www pointing to the server’s IP. The same one you are currently pointing the [domain.com](http://domain.com) A record to.

---

<div class="post-metadata">

### Author: ![Erik\_Manger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erik_manger/32/179399_2.png) [@Erik\_Manger](https://meta.discourse.org/u/Erik_Manger)
#### Post date: [May 8, 2020, 4:33am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/3 "2020-05-08T04:33:22Z")

</div>

Will this cause issues when the user visits using the www version? Discourse is set to not have the www included.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [May 8, 2020, 5:37am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/4 "2020-05-08T05:37:47Z")

</div>

No because the user will be redirected. It won’t serve the same site under multiple domains.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [May 8, 2020, 6:04am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/5 "2020-05-08T06:04:07Z")

</div>

You want these guides. I used them for the same exact purpose:

> [@(Superseded) Redirect additional domain(s) to your Discourse instance](https://meta.discourse.org/t/redirect-single-multiple-domain-s-to-your-discourse-instance/18492):
>
> warning 2024-04-09 @pfaffman edited this to say that this is no longer necessary, as the current NGINX config in the [standard install](https://meta.discourse.org/t/142537?silent=true) redirects everything to https://HOSTNAME. You can test this by entering your IP address and see that it gets redirected. If you want multiple domains pointed to your server, you probably want them to have valid https certificates. To do that, follow instructions at [Set up Let’s Encrypt with multiple domains / redirects](https://meta.discourse.org/t/set-up-let-s-encrypt-with-multiple-domains-redirects/56685). So you want to redirect domain(s) to yo…

> [@Set up Let’s Encrypt with multiple domains / redirects](https://meta.discourse.org/t/setting-up-let-s-encrypt-with-multiple-domains/56685):
>
> NOTE: @pfaffman says: This page needs to be cleaned up. There is now a new ENV setting that will let you add more hostnames. In your app.yml under your DISCOURSE\_HOSTNAME line (it can go many places but that one makes sense), add DISCOURSE\_HOSTNAME\_ALIASES: domain.com,other.domain.com and early reports suggest that you’ll get valid certs for those domains and that accessing https://domain.com will properly redirect you to your DISCOURSE\_HOSTNAME without a certificate error. If you do that an…

---

<div class="post-metadata">

### Author: ![Erik\_Manger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erik_manger/32/179399_2.png) [@Erik\_Manger](https://meta.discourse.org/u/Erik_Manger)
#### Post date: [May 8, 2020, 8:29pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/6 "2020-05-08T20:29:21Z")

</div>

Are you saying adding the A record for ‘www’ isn’t enough? I read through those articles.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [May 8, 2020, 8:32pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/7 "2020-05-08T20:32:36Z")

</div>

My site would get a nasty message on the browser without registering a certificate for both “sub-domains”.

---

<div class="post-metadata">

### Author: ![Ray5](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@Ray5](https://meta.discourse.org/u/Ray5)
#### Post date: [May 9, 2020, 10:21pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/8 "2020-05-09T22:21:51Z")

</div>

I’ve just set up Discourse on a Digital Ocean droplet. For step 2, editing discourse.conf, does that require nginx to be installed? I’m not certain but I don’t think my droplet has nginx installed and I’m at a loss with how to install it.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 10, 2020, 1:19am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/9 "2020-05-10T01:19:12Z")

</div>

I think this guide explains that part:

[https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247/294](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247/294)

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [May 10, 2020, 1:22am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/10 "2020-05-10T01:22:10Z")

</div>

Yes adding an a record for www aimed at the same IP will be adequate to redirect the traffic.

You don’t need to do anything outlined in those other guides, an A record pointed to the IP will suffice for a simple redirect.

Try not to complicate your install unless absolutely necessary.

---

<div class="post-metadata">

### Author: ![Ray5](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@Ray5](https://meta.discourse.org/u/Ray5)
#### Post date: [May 10, 2020, 7:43am UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/11 "2020-05-10T07:43:10Z")

</div>

Will this be enough to avoid a `NET::ERR_CERT_COMMON_NAME_INVALID` browser error though? If I install discourse on the www subdomain, accessing the site with [https://example.com](https://example.com) gives me that error. It only works if you use [https://www.example.com](https://www.example.com).

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [May 10, 2020, 1:12pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/12 "2020-05-10T13:12:18Z")

</div>

That’s why you want to use a redirect, discourse can’t be served from multiple URLs.

Pick one, redirect the other.

---

<div class="post-metadata">

### Author: ![Milo](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Milo](https://meta.discourse.org/u/Milo)
#### Post date: [May 10, 2020, 2:00pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/13 "2020-05-10T14:00:49Z")

</div>

I have a similar issue and using a URL redirect record at the DNS level doesn’t solve the problem for me.

I installed Discourse using the hostname ‘[www.example.com](http://www.example.com)’ and the following DNS records:

```
A Record host:WWW value:my_server_ip
CNAME host:@ value: www.example.com
URL Redirect Record host:@ value:https://www.example.com

```

If I then use [SSL Server Test (Powered by Qualys SSL Labs)](https://www.ssllabs.com/ssltest/index.html) to check the URL `https://example.com` **without the WWW** I get a Certificate name mismatch and in my browser a `NET::ERR_CERT_COMMON_NAME_INVALID` error.

Apologies again if I’m missing something obvious here, networking isn’t my strong point!

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [May 12, 2020, 1:32pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/14 "2020-05-12T13:32:07Z")

</div>

Hence why I posted those links. I’d love it to be as simple as a DNS change. It didn’t seem to be that simple to me either. To work via https I had to ensure that a cert was being registered for both addresses. To achieve that use one of the guides I posted above. The other guide allows you to perform a redirect.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [May 12, 2020, 2:02pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/15 "2020-05-12T14:02:06Z")

</div>

Users are very unlikely to specify the protocol when typing in a URL. If you’re really worried about it you can just use Cloudflare for DNS and a simple page rule.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [May 12, 2020, 2:04pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/16 "2020-05-12T14:04:42Z")

</div>

Yeah, I ‘moved’ my domain (well I just chose to cut off the www) which is why I had to serve existing links already on sites I didn’t control referring to my old domain _with_ https. That might explain why in my case I had no choice but to do the full job.

So what I think you are saying is, if you are just happy to have someone type in [www.example.com](http://www.example.com) and for it to be redirected to [https://example.com](https://example.com) requires only a DNS change?

However, if for any reason you want [https://www.example.com](https://www.example.com) to work (in my case I did because such links were already ‘out there’) you have to follow the provided guides

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [May 12, 2020, 2:25pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/17 "2020-05-12T14:25:44Z")

</div>

Or just use a page rule as stated above. It will front the domain using a wildcard cert and redirect the traffic seamlessly.

All with zero additional complexity on the Discourse server.

---

<div class="post-metadata">

### Author: ![Milo](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Milo](https://meta.discourse.org/u/Milo)
#### Post date: [May 12, 2020, 6:45pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/18 "2020-05-12T18:45:51Z")

</div>

> [@Stephen](#):
>
> Or just use a page rule

What’s a page rule?

I’m intending to follow [How To Install Discourse Behind Nginx on Ubuntu 14.04 | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-discourse-behind-nginx-on-ubuntu-14-04) to install Nginx on my Digital Ocean droplet and then apply the rules listed in “step 2” to redirect to the correct domain. I think this should work! I’ll try it tomorrow and see if it allows me to redirect all combinations of [https://www](https://www)., [http://www](http://www), [http://domain.com](http://domain.com), [https://domain.com](https://domain.com) to my discourse hostname which the Lets Encrypt cert which is is [https://www.domain.com](https://www.domain.com).

We’ll see!

---

<div class="post-metadata">

### Author: ![syl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/syl/32/98883_2.png) [@syl](https://meta.discourse.org/u/syl)
#### Post date: [May 14, 2020, 3:22pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/19 "2020-05-14T15:22:42Z")

</div>

@Erik_Manger, DNS-based solutions didn’t work for me with SSL. I used the first link provided by @merefield and it works well.

---

<div class="post-metadata">

### Author: ![Milo](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Milo](https://meta.discourse.org/u/Milo)
#### Post date: [May 14, 2020, 3:43pm UTC](https://meta.discourse.org/t/making-www-work-with-discourse/150785/20 "2020-05-14T15:43:51Z")

</div>

Did you need to install Nginx in-front of Discourse to get this to work? On my Digital Ocean droplet the path “/etc/nginx/” used in the additional hooks doesn’t exist.

[Next page](https://meta.discourse.org/t/making-www-work-with-discourse/150785.md?page=2)
