I changed the custom domain on my Heroku app to a new one. Now I will create a new Heroku app which only purpose will be to redirect to the first app.
I read in Google
You can do this in the routes.rb file rather than a controller:
routes.rb
Rails.application.routes.draw do constraints(host: 'old.com') do get '(*)', to: redirect(host: 'new.com') end # your existing routes here end
This will do a 301 redirect, which is the default for the redirect route helper