views:

1598

answers:

2

I'm trying to get Redmine (a Ruby on Rails app) working. It works fine when started with ruby script/server webrick -e production, however, I'm having trouble getting it working in Apache with Passenger.

Accessing http://example.com/redmine returns the Redmine home page, but clicking any link (or even adding a / to the URL) results in a 404. According to the Rails log, a RoutingError occurs. For example, when opening the projects page: ActionController::RoutingError (No route matches "/projects.html" with {:method=>:get})

The Redmine directory is /var/www/localhost/htapps/redmine. I followed the documentation at http://www.modrails.org/documentation/Users%20guide.html#_deploying_a_ruby_on_rails_application (section 3.2), so there's a symlink at /var/www/localhost/htdocs/redmine pointing to ../htapps/redmine/public, and the Apache configuration contains DocumentRoot /var/www/localhost/htdocs and RailsBaseURI /redmine.

What is causing it to raise these RoutingErrors?

A: 

http://ptspts.blogspot.com/2009/05/how-to-fix-railsbaseuri-sub-uri-with.html

The manual workaround (according to what is suggested on the pages above) is adding the line below to config/environments/production.rb:

config.action_controller.relative_url_root = '/redmine'

Corban Brook
I think that that blog post describes a different issue. Their error message shows that the path includes 'myapp' (which would be 'redmine' in this case). My error message doesn't include that. In any case, I tried this workaround, but it results in a startup error: 'undefined method `relative_url_root=' for ActionController::Base:Class'
Zr40
+1  A: 

It looks like this issue was actually caused by the default .htaccess included with Redmine.

Redmine's .htaccess rewrites every request to end with .html. Redmine's routes expect .html-less requests.

Setting RewriteEngine to Off solved the issue for me.

Zr40