Dorian Dorian - 7 months ago 10
Ruby Question

Deploy a rails application in a sub-directory with Passenger

I have a website : http://foo.com
I would like to add a rails application in : http://foo.com/subdir
So I use a Apache Proxy to do it.

In the server with the Rails application, I have Passenger and Apache, and my VirtualHost :

<VirtualHost *:80>
ServerName 1.2.3.4

DocumentRoot /path/to/railsapp/public
RailsEnv production
</VirtualHost>


And when I go to http://foo.com/subdir, all the paths are incorect (http://foo.com/images, http://foo.com/users, ... etc) but what I would like is a subdirectory like (http://foo.com/subdir/images, http://foo.com/subdir/users, ... etc)

So how could I do it please ?

PS : I tried RailsBaseURI, but it don't work :(.

Answer

I moved my application to subdir/

I created a .htaccess with :

PassengerEnabled on
PassengerAppRoot /path/to/railsapp/subdir

And my VirtualHost :

  DocumentRoot /path/to/railsapp/  
  <Directory /path/to/railsapp/subdir>
    AllowOverride All
    RailsBaseURI /subdir
  </Directory>

Thanks AlexD for trying to help me.