Two domains, conditional redirect

Dear Discourse experts!

We have been running a discourse forum (DOMAIN1) for 3 years. Now we want expand the discussion scope and add DOMAIN2. We succeeded getting them both active with letsencrypt thanks to this post. We will keep both domains active which worked after step 1 on this post. The second is redirected to the main domain name, which is good.

Part of the transition is to move all existing categories to a new top level category.

DOMAIN2 will become the main discourse domain, DOMAIN1 will remain linked so external links to posts still work.

Here is the question: How can we add a redirect if a “vanilla” DOMAIN1 is called (just the root URL, no path) to the new top level category URL? All other DOMAIN1 calls (with paths) should keep the existing path (no change, already works). Doing this will minimize confusion since everyone going to the DOMAIN1 will land in the category and everything will look similar as before.

Hope someone has a suggestions how add this conditional redirect with our double domain setup.

Thank you!

1 Like

You’re going to have a hard time: A single Discourse instance cannot live at multiple URLs; and permalink redirection does not function for existing routes such as topic view.


So you’re saying there isn’t a simple way to do the following?

(1) go to and it’s running discourse (with main hostname - works)
(2) go to and it goes to (what we also want)
(3) go to and it shows either or (current works)

we are transitioning and want only the root of to redirect to a category. is there any sort of URL rewriting that can do this?

1 Like

If domain2 is only serving redirection rules, then yes you can write an nginx config to do that; the details of which are out of scope for Meta.


Could not the site map plugin serve as the raw data for the nginx 302 redirects?

1 Like

We got it working by adding the following to the web.ssl.template.yml file:

if ($host = {
    rewrite ^/$ /c/example/18 permanent;

Please move that to a replace directive in your app.yml instead, or future upgrades are going to be a pain for you!


Ok thanks for that!!!

1 Like