# צריך עזרה בהפניה מחדש לאחר שינוי הדומיין של פורום ה-Discourse שלי

**URL:** https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964
**Category:** Self-hosting
**Created:** [21 באוגוסט,‏ 2023,‏ 1:29am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964 "2023-08-21T01:29:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Anirudh\_Dutta\_Gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anirudh_dutta_gupta/32/198914_2.png) [@Anirudh\_Dutta\_Gupta](https://meta.discourse.org/u/Anirudh_Dutta_Gupta)
#### Post date: [21 באוגוסט,‏ 2023,‏ 1:29am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/1 "2023-08-21T01:29:06Z")

</div>

After moving my Discourse forum to a new instance and URL, I need help with setting up domain redirection.

I want links from the old domain to redirect to the new domain. For example, a link like [https://olddomain.com/t/topic/89520](https://olddomain.com/t/topic/89520) should redirect to [Parked at Loopia](https://newdomain.com/t/topic/89520).

I’ve heard about using a 301 redirect, but I’m struggling to locate the Nginx configuration directory on my server. Any alternative solutions or guidance would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [21 באוגוסט,‏ 2023,‏ 1:59am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/2 "2023-08-21T01:59:59Z")

</div>

Hi @Anirudh_Dutta_Gupta 👋 welcome to Meta 🙂

Have you seen this topic yet:

> [@Redirect old forum URLs to new Discourse URLs using permalinks](https://meta.discourse.org/t/redirect-old-forum-urls-to-new-discourse-urls/20930/1):
>
> Redirecting Old Forum URLs to New Discourse URLs using permalinks If you’ve moved from other forum software to Discourse using [one of our import scripts](https://github.com/discourse/discourse/tree/main/script/import_scripts), then you probably want all your hard-earned Google search results to continue pointing to the same content. Discourse has a built-in way to handle this for you as an alternative to writing nginx rules, using the permalinks lookup table. The permalinks table allows you to set two things: a url to match, and what that url should show. There a…

---

<div class="post-metadata">

### Author: ![Anirudh\_Dutta\_Gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anirudh_dutta_gupta/32/198914_2.png) [@Anirudh\_Dutta\_Gupta](https://meta.discourse.org/u/Anirudh_Dutta_Gupta)
#### Post date: [21 באוגוסט,‏ 2023,‏ 10:15am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/3 "2023-08-21T10:15:15Z")

</div>

Thank you @Lilly. I’d like to know if permalinks can handle a full domain change too. Just to clarify, we’re moving from [abc.domain1.com](http://abc.domain1.com) to [xyz.domain2.com](http://xyz.domain2.com). Both the subdomain and the domain are changing. I’ve been reading through [this discussion](https://meta.discourse.org/t/discourse-to-wordpress-redirect-questions/87031/2) and wanted to confirm:

> Are you trying to redirect an existing Discourse topic to an external URL? That’s not what permalinks are designed to do. I’m pretty sure that you can’t redirect anything under /t.  
> If you want people who visit [https://hoidap.cheng.vn/t/cach-cua-do-nu-bao-binh-don-gian/70](https://hoidap.cheng.vn/t/cach-cua-do-nu-bao-binh-don-gian/70) 2 to be redirected to [https://cunghoangdao.info](https://cunghoangdao.info) then I think your best bet is to edit the post and tell people to click the link to go to the other site.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [21 באוגוסט,‏ 2023,‏ 10:24am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/4 "2023-08-21T10:24:39Z")

</div>

So you set up

- a generic redirect on [abc.domain1.com/anything](http://abc.domain1.com/anything) to [xyz.domain2.com/anything](http://xyz.domain2.com/anything)
- permalink redirects on [xyz.domain2.com/foo/bar](http://xyz.domain2.com/foo/bar) to /t/1234

---

<div class="post-metadata">

### Author: ![Anirudh\_Dutta\_Gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anirudh_dutta_gupta/32/198914_2.png) [@Anirudh\_Dutta\_Gupta](https://meta.discourse.org/u/Anirudh_Dutta_Gupta)
#### Post date: [21 באוגוסט,‏ 2023,‏ 10:51am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/5 "2023-08-21T10:51:33Z")

</div>

Thank you @RGJ. How do I go about with the generic redirect? Both the current and the previous forums are on Discourse.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [21 באוגוסט,‏ 2023,‏ 11:33am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/6 "2023-08-21T11:33:18Z")

</div>

Assuming you’re going to remove the current forum, it’s just a normal Apache or nginx redirect.

For nginx

```plaintext
server {
    server_name original.example.com;
    location / {
        rewrite ^/(.*)$ https://new.example.com/$1 permanent;
    }
}

```

or Apache

```plaintext
RewriteEngine On
RewriteRule ^(.*)$ https://new.example.com/$1 [R=301,L]

```

I had missed the part where you’re only moving Discourse and not migrating. Since you’re only moving domains, you don’t need the permalink redirects.

---

<div class="post-metadata">

### Author: ![Anirudh\_Dutta\_Gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anirudh_dutta_gupta/32/198914_2.png) [@Anirudh\_Dutta\_Gupta](https://meta.discourse.org/u/Anirudh_Dutta_Gupta)
#### Post date: [21 באוגוסט,‏ 2023,‏ 11:35am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/7 "2023-08-21T11:35:22Z")

</div>

That’s what I was originally thinking, but I cannot find the nginx folder anywhere in the /etc directory. Am I looking in the wrong place?

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [21 באוגוסט,‏ 2023,‏ 11:38am UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/8 "2023-08-21T11:38:17Z")

</div>

That’s because there is currently a Discourse install there, which has the nginx in the container.

It would be easiest to point the old hostname to the new instance and handle the redirection there see [URL rewrite for domain change in permalinks - #7 by modius](https://meta.discourse.org/t/url-rewrite-for-domain-change-in-permalinks/58507/7)

Alternatively, remove the Discourse install and set up nginx on the old instance

---

<div class="post-metadata">

### Author: ![Anirudh\_Dutta\_Gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anirudh_dutta_gupta/32/198914_2.png) [@Anirudh\_Dutta\_Gupta](https://meta.discourse.org/u/Anirudh_Dutta_Gupta)
#### Post date: [21 באוגוסט,‏ 2023,‏ 3:11pm UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/9 "2023-08-21T15:11:40Z")

</div>

Thank you @RGJ for the guidance. I just ended up doing a domain level direct from our domain name provider, and that worked. The old links are redirecting to the new links correctly.

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [21 באוגוסט,‏ 2023,‏ 3:17pm UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/10 "2023-08-21T15:17:39Z")

</div>

Here is the method I use for a full redirection after a domain change, I mixed a few solutions offered in this forum.

in the app.yml, at the end I add the after\_web\_config and after\_ssl blocks :

```yml
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - 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;
            listen 443 ssl;
            server_name old-domain.com;
            return 301 $scheme://new-domain.com$request_uri;
          }
  after_ssl:
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d old-domain.com --keylength"

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

```

It will redirect the old links to the new forums, without a SSL issue.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [20 בספטמבר,‏ 2023,‏ 3:18pm UTC](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964/11 "2023-09-20T15:18:15Z")

</div>

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