Ruby on Rails
HowToSetTheBaseURLsOfYourRailsApps

The default rails Installation Instructions walks you though setting up a single Rails application that comprises your entire web site (in other words, the ApplicationRoot is the same as the web server’s DocumentRoot). Perhaps this is all you want.

Frequently, however, you will want a little more flexibility; perhaps you want to integrate your Rails application into an existing web site (with the \ApplicationRoot as a sub-directory of the webserver’s \DocumentRoot). Or maybe you want to run multiple independent Rails applications each with its own strategically placed \ApplicationRoot, or in sub-domain (virtual server). How to do all of that and more can be found here.

The simplest solution

For all but the most complicated situations, you can simply create SymLinks somewhere under your \DocumentRoot pointing to the public directory of your Rails application (which is the \ApplicationRoot, as far as the webserver is concerned). If you need more detailed instruction read about HowtoUseSymLinksToGraftRailsOntoYourWebsite.

Creating a virtual host

Sometimes you may want your application to have its own \DocumentRoot all to itself. In other words, you want the application to live at the document root—yet you may also want to have more than one application on the machine. To do this you need to know HowToCreateVirtualHostsForRailsAppllications

Using mod_rewrite or mod_alias under Apache

Another, only slightly more involved technique is to use Apache’s mod_alias to map the URLs you want to use to the directory containing your application, as explained in HowToUseRailsWithAliasedURLs.

It is also possible to use something like Apache’s mod_rewrite, and get as fancy as you’d like, provided that you know HowToUseRailsWithRewrittenURLs

Note that neither of these methods is as popular in the Rails community since the introduction of Routes, which provide much of the same functionality within Rails itself.

Special needs

If none of the above suffice, you may find what you want in

…if not, feel free to add a page here describing your situation and as much as you know about posible solutions.

category: Howto