Tobias Neumann
2006-Jul-02 14:53 UTC
[Rails] Use mod_rewrite rules instead of rails-routes
Hi 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$ /keywords/show?id=$2&page=$3 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 "/foo/bar/index.123.4.html".>From the rewrite log I can see that the rewriting process is also notdone correctly: applying pattern ''^(.*\/)*index\.([0-9]+)\.([0-9]+)\.html$'' to uri ''foo/bar/index.123.4.html'' rewrite ''foo/bar/index.123.4.html'' -> ''/keywords/show?id=123&page=4'' split uri=/keywords/show?id=123&page=4 -> uri=/keywords/show, args=id=123&page=4 add path info postfix: /keywords/show -> /keywords/show/bar/index.123.4.html 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 recognize) 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