How can I use Rails routes to redirect from one domain to another?

后端 未结 6 904
栀梦
栀梦 2020-12-02 23:59

My app used to run on foo.tld but now it runs on bar.tld. Requests will still come in for foo.tld, I want to redirect them to bar.tld.

How can I do this in rails rou

6条回答
  •  有刺的猬
    2020-12-03 00:13

    Bit more modern approach:

    constraints(host: 'www.mydomain.com') do
        get '/:param' => redirect('https://www.mynewurl.com/:param')
    end
    

提交回复
热议问题