# (Superseded) Redirect additional domain(s) to your Discourse instance

**URL:** https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492
**Category:** Self-Hosting
**Tags:** how-to
**Created:** [August 5, 2014, 10:46am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492 "2014-08-05T10:46:41Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![wesnolte](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesnolte/32/122079_2.png) [@wesnolte](https://meta.discourse.org/u/wesnolte)
#### Post date: [December 5, 2015, 12:16am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/47 "2015-12-05T00:16:19Z")

</div>

I am experiencing some odd behaviour, with one `file` block everything works perfectly. When I add the second file block (copy-paste, edit `server_name`) and then rebuild I get a “Too many redirects” error on all domains. If I remove all but 1 file block, everything is fine again. If I run `curl -vso dev/null www.mydomain.com` it’s saying that there’s a redirect on the `www.mydomain.com`! Not sure what I’m doing wrong, config is below:

```
  after_web_config:
    - replace:
        filename: /etc/nginx/nginx.conf
        from: /sendfile.+on;/
        to: |
          server_names_hash_bucket_size 64;
          sendfile on;
    - file:
        path: /etc/nginx/conf.d/www_redirect.conf
        contents: |
          server {
            listen 80;
            server_name mydomain.com;
            return 301 $scheme://www.mydomain.com$request_uri;
          }
    - file:
        path: /etc/nginx/conf.d/c_redirect.conf
        contents: |
          server {
            listen 80;
            server_name community.mydomain.com;
            return 301 $scheme://www.mydomain.com$request_uri;
          }

```

Any ideas?

---

<div class="post-metadata">

### Author: ![ch.ali.sabir](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ch.ali.sabir/32/122036_2.png) [@ch.ali.sabir](https://meta.discourse.org/u/ch.ali.sabir)
#### Post date: [January 16, 2016, 9:59pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/48 "2016-01-16T21:59:43Z")

</div>

@techAPJ

My use case is something like this:

1. I want to host a single instance of Discourse which should serve against multiple domains.
2. This single instance will have categories/topics associated with multiple domains.
3. When the instance is requested from a domain, the discourse must return only those categories/topics which belong to that domain.

Example: Suppose I have a single instance of discourse hosted as: [mydiscouseinstance.com/forums](http://mydiscouseinstance.com/forums)  
Now, some categories/topics in this instance can belong to a domain say [mydomainone.com/forums](http://mydomainone.com/forums)  
whereas some categories/topics in this instance can belong to another domain say [mydomaintwo.com/forums](http://mydomaintwo.com/forums). When I pass URL [mydomainone.com/forums](http://mydomainone.com/forums) to [mydiscouseinstance.com/forums](http://mydiscouseinstance.com/forums), it should only display those categories/topics which belong to [mydomainone.com](http://mydomainone.com).

How can I achieve that?

In Joomla, it is possible through a plugin like: [Virtual Domains - Joomla! Extension Directory](http://extensions.joomla.org/extension/virtual-domains)

Can we do something like that in Discourse too? Thanks for any possible help.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 17, 2016, 12:24am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/49 "2016-01-17T00:24:23Z")

</div>

This is not supported and will not work.

---

<div class="post-metadata">

### Author: ![Vikas\_Dangi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vikas_dangi/32/131628_2.png) [@Vikas\_Dangi](https://meta.discourse.org/u/Vikas_Dangi)
#### Post date: [July 19, 2016, 6:08pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/50 "2016-07-19T18:08:52Z")

</div>

I have done all coding work to my website, but have little confusion of updating DNS record. I am redirecting from [example.com](http://example.com) to [www.example.com](http://www.example.com), so what I have to update in A record.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 20, 2016, 2:04am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/51 "2016-07-20T02:04:16Z")

</div>

A record should be for www in that case, sounds correct, then redirect “naked” domain to www.

---

<div class="post-metadata">

### Author: ![Jay\_Patel](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@Jay\_Patel](https://meta.discourse.org/u/Jay_Patel)
#### Post date: [December 17, 2016, 8:57am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/52 "2016-12-17T08:57:29Z")

</div>

without following above guide directly changed nginx.conf? i just want only www website on root domain.

---

<div class="post-metadata">

### Author: ![Jay\_Patel](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@Jay\_Patel](https://meta.discourse.org/u/Jay_Patel)
#### Post date: [December 18, 2016, 7:53am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/53 "2016-12-18T07:53:33Z")

</div>

for already running discourse just changing app.yml and rebuild will work without loosing data?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [December 18, 2016, 2:21pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/54 "2016-12-18T14:21:37Z")

</div>

> [@Jay\_Patel](#):
>
> for already running discourse just changing app.yml and rebuild will work without loosing data?

That is correct. A rebuild will not lose any data

---

<div class="post-metadata">

### Author: ![Jay\_Patel](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@Jay\_Patel](https://meta.discourse.org/u/Jay_Patel)
#### Post date: [December 18, 2016, 4:50pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/55 "2016-12-18T16:50:19Z")

</div>

Thank you @cpradio It works like charm 🙂

---

<div class="post-metadata">

### Author: ![Jay\_Patel](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@Jay\_Patel](https://meta.discourse.org/u/Jay_Patel)
#### Post date: [December 18, 2016, 6:49pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/56 "2016-12-18T18:49:47Z")

</div>

do listen port needs to be 443 in hooks or both ? i have redirect to non-www to www with www A record set.

Thanks,  
Jay

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [December 18, 2016, 6:51pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/57 "2016-12-18T18:51:44Z")

</div>

non-www to www has nothing to do with port 443, port 443 is for SSL.

---

<div class="post-metadata">

### Author: ![Jay\_Patel](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@Jay\_Patel](https://meta.discourse.org/u/Jay_Patel)
#### Post date: [December 18, 2016, 6:54pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/58 "2016-12-18T18:54:30Z")

</div>

> [@cpradio](#):
>
> non-www to www has nothing to do with port 443, port 443 is for SSL.

so if lets encrypt is on listen should be 443 right ?  
Thanks

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [December 18, 2016, 7:54pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/59 "2016-12-18T19:54:00Z")

</div>

Yes, that would be correct.

---

<div class="post-metadata">

### Author: ![Jay\_Patel](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@Jay\_Patel](https://meta.discourse.org/u/Jay_Patel)
#### Post date: [December 19, 2016, 5:52am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/60 "2016-12-19T05:52:49Z")

</div>

I did turned on https first then did redirect from non-www to www but its keep redirecting and end up not loading up discourse.  
Thanks.

---

<div class="post-metadata">

### Author: ![edanto](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@edanto](https://meta.discourse.org/u/edanto)
#### Post date: [January 11, 2017, 6:33am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/61 "2017-01-11T06:33:16Z")

</div>

I plan to use this approach to have [chat.example.com](http://chat.example.com) as the permanent URL to our site; even if the real URL changes over time (e.g if we move to Discourse hosting etc).

Am I correct to think that mobile Discourse app users who have configured the app with [chat.example.com](http://chat.example.com) will not be affected by any hosting change; once the steps above are followed during the hosting change window?

---

<div class="post-metadata">

### Author: ![ffhaddad](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@ffhaddad](https://meta.discourse.org/u/ffhaddad)
#### Post date: [December 16, 2017, 12:05am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/63 "2017-12-16T00:05:22Z")

</div>

These instructions aren’t working for me. Is it because the root domain in the Discourse settings is [sunrisepoint.org](http://sunrisepoint.org) instead of [www.sunrisepoint.org](http://www.sunrisepoint.org)?

I’m trying to map [sunrisepoint.org](http://sunrisepoint.org) to [www.sunrisepoint.org](http://www.sunrisepoint.org).

Also, if I have https enabled, do the instructions need to be tweaked?

---

<div class="post-metadata">

### Author: ![roxy](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@roxy](https://meta.discourse.org/u/roxy)
#### Post date: [July 27, 2018, 7:13pm UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/64 "2018-07-27T19:13:03Z")

</div>

hi.

we are getting several 404 not found errors in our console due to changes in category names. can we redirect those addresses to an existing address using this tutorial?

---

<div class="post-metadata">

### Author: ![vitorl](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@vitorl](https://meta.discourse.org/u/vitorl)
#### Post date: [September 25, 2018, 5:02am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/65 "2018-09-25T05:02:20Z")

</div>

really interested in this…any new development ? also if I’m using a CDN, I can’t know my server IP right? Or should I use me A record IP even if it’s not public knowledge ( cloudflare is proxying it, so it’s hidden )

---

<div class="post-metadata">

### Author: ![vitorl](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@vitorl](https://meta.discourse.org/u/vitorl)
#### Post date: [September 25, 2018, 5:03am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/66 "2018-09-25T05:03:22Z")

</div>

What about redirecting https www to non www? Can’t find a portable way to this with the docker

---

<div class="post-metadata">

### Author: ![Gulshan\_Kumar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gulshan_kumar/32/119562_2.png) [@Gulshan\_Kumar](https://meta.discourse.org/u/Gulshan_Kumar)
#### Post date: [September 25, 2018, 7:12am UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/67 "2018-09-25T07:12:50Z")

</div>

An easy way -

1. Go to Cloudflare

2. Add your domain

3. Update Cloudflare nameservers

4. At Cloudflare DNS Page, point IP address to your host. Turn on Cloudflare proxy.  
A - old.tld - hosting IP  
CNAME - www - old.tld

5. Go to Crypto menu \> SSL mode, set Flexible

6. Go to page rule, create a new forwarder

From

```plaintext
*old.tld/*

```

To

```plaintext
https://new.tld/$2

```

That’s all.

Now all request from http/https/http-www/https-www of `old.tld` will goes to `https://new.tld` domain.

[Previous page](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492.md?page=2)

[Next page](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492.md?page=4)
