Forum: Ruby on Rails Multiple domain name, One Rails application, is this possibl

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.
Human D. (Guest)
on 2006-04-17 03:24
(Received via mailing list)
Hello folks,
I'm new to the Rails framework and don't know where to look to find my

Here is the question, Is there a way to set multiple domain name for *a*
rails application, and base on the URL do the work in the app.
Imagine I have a user based document management system, each user want
access to her docs using her domain, but I don't like to have many rails
just for multiple domains, is there a way to show the users' docs base
the URL?

Any pointer to any book, article or direct answer is extremely

Thanks in advance,
Dean W. (Guest)
on 2006-04-17 03:36
(Received via mailing list)
Yes, I'm doing this with my sites (e.g., and
links therein). My sites are all registered to go the same IP address
and my ApplicationController (application.rb) defines a
"before_filter" method that looks at the value of "" to
determine which site the user is on.

A tricky bit is testing locally, e.g., "localhost:3000" obviously
isn't the same as "". To support this, you can add
some development hooks, like a special request parameter or
environment variable to force the one you want. Another possibility is
to define another configuration (in addition to the usual "test",
"production", etc.) A disadvantage of this approach is that you won't
be able to surf between "fake" domains, as only one will be supported
at a time.

By the way, I also run typo as a separate application. I handle this
through the lighttpd configuration, as described in numerous places on
the web.

Hope this helps.


Dean W.
Grant Neufeld (Guest)
on 2006-04-17 10:22
(Received via mailing list)
For testing purposes, you can 'fake' various domain names to point at
your local server. The domains can be real or fake domain names, and
all should be pointed at the "localhost" ip address (

On *nix & Mac OS X, edit the /etc/hosts file. E.g.: my.example.tld another.test.tld etc.domain.tld

On Mac OS X, there are a couple extra steps. First, in the terminal,
run the command:
   sudo niload -v hosts . < /etc/hosts
That will copy the hosts into NetInfo.

You probably also need to add the hosts as 'machines' in NetInfo,
too. For each host:
  sudo niutil -create / /machines/my.example.tld
  sudo niutil -createprop / /machines/my.example.tld ip_address

With that, you'll be able to access a server running on your system
with any of the domain names you used.

Note that doing the above prevents you from accessing the actual
servers at those domains if they are real domains on other computers.
So, don't forget to roll that stuff back later!

To roll back:

Delete or comment-out the domains you added in the /etc/hosts file.

On Mac OS X, you can use the NetInfo Manager application
(/Applications/Utilities/NetInfo Manager) to delete the appropriate
entries from the "machines" directory. (Be sure to not mess with the
"localhost" entry, though.)
Ray B. (Guest)
on 2006-04-17 10:43
(Received via mailing list)
Grant Neufeld wrote:
> the command:
I don't have to do any of these extra steps on Mac OS X 10.4.6.

>   sudo niload -v hosts . < /etc/hosts

According to man niload

Most  processes  on  Mac  OS X access the information from the files in
/etc and from NetInfo indirectly through the  system  library  and  the
lookupd  daemon.   In some cases the files in /etc are consulted before
NetInfo, making it unnecessary to copy  information  from  these  files
into  NetInfo.   The  files  /etc/hosts,  /etc/networks, /etc/services,
/etc/protocols, and /etc/rpcs are consulted before NetInfo.

Editing /etc/hosts is much simpler. Rolling back is simpler also.


Christian K. (Guest)
on 2006-04-17 15:08
If you want to do the same thing under Windows XP, run (Start -> Run)

    notepad C:\WINDOWS\system32\drivers\etc\hosts

The file you'll see works excatly like its *nix counterparts.
Adrian L. (Guest)
on 2007-04-13 17:23
Hi, I'm newbie and facing this situation too. I have several questions:

1. can and point to the same
[app]/controller/application.rb ?

2. can and
point to the same [app]/controller/another/controller.rb ? or should
they point to [app]/controller/domain_controler/another/controller.rb ?

3. i'm a beginner in using cpanel. can this domain management thing be
done with cpanel? -- and which one should i use, the 'addon domain'
menu, or 'parked domain' menu?

thanks in advance

kind regards,

Adrian L.
on 2007-04-13 17:39
(Received via mailing list)
On Apr 13, 6:23 am, Adrian L. <removed_email_address@domain.invalid>
> done with cpanel? -- and which one should i use, the 'addon domain'
> menu, or 'parked domain' menu?
> thanks in advance
> kind regards,
> Adrian L.
> --
> Posted via

google for subdomains and account keys:
Adrian L. (Guest)
on 2007-04-13 18:49
removed_email_address@domain.invalid wrote:
> google for subdomains and account keys:

thanks for your kind reply

I've successfully used SubdomainAsAccountKeys in my previous
but it is not what I'm trying to do now

if SubdomainAsAccountKeys give the user a subdomain account, what I am
trying to do now is to give the user a domain account.

I've tried to google for this problem previously, and google lead me to
this page :)

enlighten me please,

Adrian L.
Peter De Berdt (Guest)
on 2007-04-14 00:34
(Received via mailing list)
On 13 Apr 2007, at 16:49, Adrian L. wrote:

> enlighten me please,

What you need to do if you want to host the same application on two
domain names, is put a ServerAlias in the Apache config file. That
way, both (or more than two) domain names will point to the same

Best regards

Peter De Berdt
Adrian L. (Guest)
on 2007-04-14 03:51
Thank you very much, that's just what I need.
I hope my webhost company will give me the access to apache's
ServerAlias :)

Peter De Berdt wrote:
Peter De Berdt (Guest)
on 2007-04-14 12:48
(Received via mailing list)
Chances are that the add-on domain option in cpanel actually adds
this line to the apache config file.

On 14 Apr 2007, at 01:51, Adrian L. wrote:

> Thank you very much, that's just what I need.
> I hope my webhost company will give me the access to apache's
> ServerAlias :)
> Peter De Berdt wrote:

Best regards

Peter De Berdt
Russell N. (Guest)
on 2007-04-17 17:32
(Received via mailing list)
You might also want to look at any options on there concerning
I'm currently using such a setup to serve multiple sites out of one app.

This topic is locked and can not be replied to.