Use mod_rewrite rules instead of rails-routes

I am trying to use mod_rewrite rules instead of rails routes (don’t ask
why…, routes are not flexible enough in my case):

Basically I have these two RewriteRules in my .htaccess file:

RewriteRule ^(.*/)index.([0-9]+).([0-9]+).html$
RewriteRule ^(.
)$ dispatch.fcgi [QSA,L]

So I want /foo/bar/index.123.4.html rewritten to
/keywords/show?id=123&page=$4 for rails.

Using apache 2.2.2 and mod_fcgid, rails recognizes the original uri

From the rewrite log I can see that the rewriting process is also not
done correctly:

applying pattern ‘^(.*/)index.([0-9]+).([0-9]+).html$’ to uri
rewrite ‘foo/bar/index.123.4.html’ -> ‘/keywords/show?id=123&page=4’
split uri=/keywords/show?id=123&page=4 -> uri=/keywords/show,
add path info postfix: /keywords/show ->
applying pattern '^(.
)$’ to uri ‘/keywords/show/bar/index.123.4.html’
rewrite ‘/keywords/show/bar/index.123.4.html’ -> ‘dispatch.fcgi’

This “add path info postfix” should not happen, it rewrites the url to
/keywords/show/bar/index.123.4.html (which finally rails does even not

Using apache 1.3.33 and mod_fastcgi I get the same rewrite log, but
rails shows now a 400 bad request error…

How can I use mod_rewrite with rails?

TIA, Tobias

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