You can pass a block to redirect
, which allows you to modify the parameters for the redirection:
get "family/:id", to: redirect { |params, request| "/family/parent?child=#{params[:id][/[0-9]+/]}" }, constraints: { id: /[A-Za-z0-9_\-:]+child?/ }
Also see the Rails documentation on redirection.