multiple virtual host?

The ServerName (and ServerAlias) need to be different for the two different virtual hosts. It's not enough to just proxy them to different internal URLs.

b

Dan Kelley wrote:

You can't just make up URLs and expect them to work on the open web... that's what DNS is for.

For using strictly on your local machine, you can make up host names and put them in your hosts file (/etc/hosts on *nix, google for it on windows).

b

Dan Kelley wrote:

I don't think this has anything to do with Rails. You would have the same problem if you were using PHP. This boils down to a mis- understanding of the purpose of the VirtualHost directive in Apache. The way virtual hosts work is to match against the Host header in the HTTP request (basically the client connects to the server using the server's IP but also provides the hostname it was initially asked to connect to). So if i set up my DNS zones so that www.blah.com and www2.blah.com both resolve to the same IP my browser will provide which of the 2 I asked for to the server when connecting. Apache then uses this information to determine which VirtualHost directive to use to process the request. The path that is being requested (the / blah.html in www.blah.com/blah.html) is part of the actual request, not the HTTP headers and thus not available to Apache at the time when it needs to make its vhost decision. If you want to do path based determination of settings you need to use a <Location> directive *within* your VirtualHost directive that set up the proxy settings you wish to use for each location. Have a look at core - Apache HTTP Server Version 2.2 for more information (assuming Apache 2.2...similar sections are available for other version of the Apache server/documentation).

Best of luck!

~Ross

The only reason "(HOST)/~(USER)/(SITENAME)" works for you is because the sysadmin of your server configured apache to map ~username to a directory in your home directory. The php then works in this scenario because it is just template files, html with php code which mod_php runs and replaces.

Rails does not work on this principle. It is for building complete, well-architected web applications. The template files (the html with ruby embedded) are not publicly accessible because Rails processes the file for us and writes the final output into the http socket output stream.

That probably sounds overly academic, but there are very good reasons why it is designed that way. Basically, if you just want to embed some code into an html file, stick with php.

b

PS: Oh, with correct configuration of apache, you can use the ~user stuff with rails as well. However, you'd need edit access to the apache config and you'd need to know what you are doing.

Dan Kelley wrote: