Skip to content

Instantly share code, notes, and snippets.

@kbaum
Created January 11, 2016 18:29
Show Gist options
  • Save kbaum/b62cadbfb47ca0c6d38b to your computer and use it in GitHub Desktop.
Save kbaum/b62cadbfb47ca0c6d38b to your computer and use it in GitHub Desktop.
def query_params_to_query(request)
query_params = request.params.except(:path, :format)
query_params.any? ? "?#{query_params.to_query}" : ""
end
#redirect apex http://viewthespace.com http://vts.com domain to www.vts.com
constraints(host: %r{^vts.com}) do
redirect_action = ->(params, _request) do
"https://www.vts.com/#{params[:path]}#{query_params_to_query(_request)}"
end
root to: redirect(redirect_action)
match '/*path', to: redirect(redirect_action)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment