Need Help with Redirection after changing the domain of my Discourse Forum

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 should redirect to

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.

1 Like

Hi @Anirudh_Dutta_Gupta :wave: welcome to Meta :slight_smile:

Have you seen this topic yet:

Thank you @Lilly. I’d like to know if permalinks can handle a full domain change too. Just to clarify, we’re moving from to Both the subdomain and the domain are changing. I’ve been reading through this discussion 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 2 to be redirected to then I think your best bet is to edit the post and tell people to click the link to go to the other site.

1 Like

So you set up


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

1 Like

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

For nginx

server {
    location / {
        rewrite ^/(.*)$$1 permanent;

or Apache

RewriteEngine On
RewriteRule ^(.*)$$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.


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?

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

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

1 Like

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.


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 :

    - exec:
        cd: $home/plugins
          - git clone

    - 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;
            return 301 $scheme://$request_uri;
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d --keylength"

## Any custom commands to run after building
  - 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=''"
  - exec: echo "End of custom commands"

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


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