Forum: Ruby on Rails URL Redirect and affect on Routes?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4070d2480bc3296fb94599d907a81b8c?d=identicon&s=25 Jason (Guest)
on 2009-04-15 04:44
(Received via mailing list)
I still don't fully understand routes, so I apologize in advance.

I have a single rails app, but multiple domains pointing to different
directories for marketing reasons. I am looking for a way to have the
secondary domain point to the

It'd want any links to to 301 redirect to
the secondary domain. Essentially, to the user everything should look
like but be
whatever on the server.

How can I handle this without affecting routes?

5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-04-15 05:16
(Received via mailing list)
On Wed, Apr 15, 2009 at 4:43 AM, Jason <> wrote:
> whatever on the server.
> How can I handle this without affecting routes?
> Thanks,
> Jason

I would handle this in the upline webserver like Apache or Nginx with
url rewriting

The primary domain can catch all calls to the directory and 301 them
to the subdomain without passing the call through to Rails
Rewrite the subdomain/whatever and pass it to RAILS/directory/whatever

This way Rails only has to deal with the call to the directory and can
safely ignore the primary domain handling (and avoid changing routes)

Andrew Timberlake

"I have never let my schooling interfere with my education" - Mark Twain
4070d2480bc3296fb94599d907a81b8c?d=identicon&s=25 Jason (Guest)
on 2009-04-16 04:59
(Received via mailing list)
Thanks, I figured this should be a Rewrite rule but was not familiar
enough with rails/routes to determine if I was making it more
complicated. I feel pretty confident in working with Apache.

Thanks much!
This topic is locked and can not be replied to.