Routes or .htaccess

Hello…I use a hosting company that allows me to run multiple ruby apps
at the same time. To do that I’m required to do a re-write (.htaccess
entry) so that at incoming http requests can be directed to the right
app port.

http://mysite.com/myrailsapp >> maps to >>
http://mysite.com:12007/myrailsapp

All I have to do is add :path_prefix and prepend the default routes in
my routes.rb file like so:
map.resources :players, :path_prefix => ‘myrailsapp’

map.connect ‘loser/:controller/:action/:id’
map.connect ‘loser/:controller/:action/:id.:format’

This creates routes like :
players GET /myrailsapp/players(.:format){
:controller=>“players”,
:action=>“index”}

Everything works fine in the program except when I go to grab an image
or reference a stylesheet. If I enter:
http://mysite.com/myrailsapp/images/logo.gif

It attempts to route it to a controller. Is this an issue I should fix
with .htaccess or routes.rb? I’ve attempted to do both without much
luck (not too good with .htaccess). I’m leaning towards some kind of
redirect in .htaccess but not sure if this is the best approach or how
to do it.
Any help is appreciated.
Thanks…Bill

The .htaccess file in your public directory has the following lines
which
you should uncomment / modify as required:

If your Rails application is accessed via an Alias directive,

then you MUST also set the RewriteBase in this htaccess file.

Example:

Alias /myrailsapp /path/to/myrailsapp/public

RewriteBase /myrailsapp

I hope that helps!

Regards,
Gustav P.

On Tue, Jul 21, 2009 at 6:56 AM, Bill McGuire <

Gustav P. wrote:

The .htaccess file in your public directory has the following lines
which
you should uncomment / modify as required:

If your Rails application is accessed via an Alias directive,

then you MUST also set the RewriteBase in this htaccess file.

Example:

Alias /myrailsapp /path/to/myrailsapp/public

RewriteBase /myrailsapp

I hope that helps!

Regards,
Gustav P.

On Tue, Jul 21, 2009 at 6:56 AM, Bill McGuire <
Gustav…thanks for the quick reply. I ended up using the following
command in .htaccess which seems to be working:

RedirectPermanent /myrailsapp /path/to/myrailsapp/public

For some reason ‘Alias’ didn’t work for me.
thanks…Bill

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs