# Discourseフォーラムのドメイン変更後のリダイレクトについてヘルプが必要です

**URL:** <https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964>\
**Category:** Self-hosting\
**Created:** [2023 年 8 月 21 日午前 1:29 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:** 1\
**Showing post:** 10

<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:** [2023 年 8 月 21 日午後 3:17 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>

ドメイン変更後の完全リダイレクトに使用する方法を以下に示します。このフォーラムで提供されているいくつかのソリューションを組み合わせています。

app.yml の最後に、after\_web\_config および after\_ssl ブロックを追加します。

```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"

## ビルド後に実行するカスタムコマンド
run:
  - exec: echo "カスタムコマンドの開始"
  ## 最初の登録の「From」メールアドレスを設定したい場合は、コメントを解除して変更してください。
  ## 最初のサインアップメールを受信したら、行を再コメントしてください。一度だけ実行する必要があります。
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "カスタムコマンドの終了"

```

これにより、SSL 問題なしに、古いリンクが新しいフォーラムにリダイレクトされます。

---

_[View the full topic](https://meta.discourse.org/t/need-help-with-redirection-after-changing-the-domain-of-my-discourse-forum/275964)._
