# (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:** [05.Август.2014 10:46:41 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:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [05.Август.2014 10:46:41 UTC](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492/1 "2014-08-05T10:46:41Z")

</div>

> ⚠ 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 your Discourse instance? Great, let’s get started!

In this tutorial we’ll show how to redirect `www.example.com` and `example.com` to `talk.example.com`.

## Update DNS Record

Update the A record for the domain(s) you want to redirect to original domain.

## Edit Configuration FIle

Open configuration file `app.yml`. From console, run these commands:

```plaintext
cd /var/discourse
git pull
nano containers/app.yml

```

Configuration file will open in _nano_ editor. Search for _hooks_ (with Ctrl+W) in the file:

```plaintext
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git

```

Add `after_web_config` block to the `hooks` (proper indentation is important):

```plaintext
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
  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/discourse_redirect_1.conf
        contents: |
          server {
            listen 80;
            server_name example.com;
            return 301 $scheme://talk.example.com$request_uri;
          }
    - file:
        path: /etc/nginx/conf.d/discourse_redirect_2.conf
        contents: |
          server {
            listen 80;
            server_name www.example.com;
            return 301 $scheme://talk.example.com$request_uri;
          }

```

You can add as many `file` blocks as you want, depending on number of domain(s) you want to redirect:

```plaintext
    - file:
        path: /etc/nginx/conf.d/discourse_redirect_3.conf
        contents: |
          server {
            listen 80;
            server_name discourse.example.com;
            return 301 $scheme://talk.example.com$request_uri;
          }

```

Modify the file name `discourse_redirect_3` and domain name to which you want to redirect `discourse.example.com` as per your need.

_Note that original domain name `talk.example.com` will remain same in all `file` blocks._

After completing your edits, press Ctrl+O then Enter to save and Ctrl+X to exit.

## Rebuild Container

Run this command:

```plaintext
./launcher rebuild app

```

Congratulations, that’s it! Try visiting `example.com` and `www.example.com`, they both will redirect to `talk.example.com`!

---

_[View the full topic](https://meta.discourse.org/t/superseded-redirect-additional-domain-s-to-your-discourse-instance/18492)._
