RoR&Apache - htaccess rewrite directories fail?

On my server I have a directory at the root, /rails/ which contains
other directories with rails projects. In my httpd.conf I have

RewriteEngine On
RewriteLog “logs/rewrite.log”
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} !^/rails/([^/]+)/public/
RewriteRule ^/rails/([^/]+)/?(.*)$ /rails/$1/public/$2 [QSA,L]

So with a GET /rails/test/ you’d get sent to /rails/test/public/ and get
the welcome screen fully functional, except for the link “About your
application’s environment” which spits out an Application Error box
underneath when clicked.
The .htaccess in the public/ dir is the default one from creating the
project and has AllowOverride all.

.htaccess:
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

A request for /rails/test/something first gets a /public/ put there in
between, and then the .htaccess takes which if I’ve gotten it right sets
the requested file to index.html if nothing was requested,
something.html if “something” does not have an extension (i.e no dot in
it) and if there is no something.html the requested file gets finally
changed to dispatch.cgi/something where a controller/view takes care of
it.
It is that last that won’t work as it should, and I’m not sure why.
/rails/test/something should become
/rails/test/public/dispatch.cgi/something
but really just becomes /rails/test/public/dispatch.cgi, the path info
is gone.

From rewrite.log:
(2) init rewrite engine with requested uri /rails/test/something
(3) applying pattern ‘^/rails/([^/]+)/?(.)$’ to uri
‘/rails/test/something’
(4) RewriteCond: input=’/rails/test/something’
pattern=’!^/rails/([^/]+)/public/’ => matched
(2) rewrite ‘/rails/test/something’ -> ‘/rails/test/public/something’
(2) local path result: /rails/test/public/something
(2) prefixed with document_root to C:/Program
Files/Apache/htdocs/rails/test/public/something
(1) go-ahead with C:/Program
Files/Apache/htdocs/rails/test/public/something [OK]
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] strip
per-dir prefix: C:/Program
Files/Apache/htdocs/rails/test/public/something -> something
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] applying
pattern ‘^$’ to uri ‘something’
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] strip
per-dir prefix: C:/Program
Files/Apache/htdocs/rails/test/public/something -> something
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] applying
pattern ‘^([^.]+)$’ to uri ‘something’
(2) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] rewrite
‘something’ -> ‘something.html’
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] add
per-dir prefix: something.html -> C:/Program
Files/Apache/htdocs/rails/test/public/something.html
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] strip
per-dir prefix: C:/Program
Files/Apache/htdocs/rails/test/public/something.html -> something.html
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] applying
pattern '^(.
)$’ to uri ‘something.html’
(4) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
RewriteCond: input=‘C:/Program
Files/Apache/htdocs/rails/test/public/something.html’ pattern=’!-f’ =>
matched
(2) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] rewrite
‘something.html’ -> ‘dispatch.cgi’
(3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] add
per-dir prefix: dispatch.cgi -> C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi
(2) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] strip
document_root prefix: C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi ->
/rails/test/public/dispatch.cgi
(1) [perdir C:/Program Files/Apache/htdocs/rails/test/public/] internal
redirect with /rails/test/public/dispatch.cgi [INTERNAL REDIRECT]
[redir#1] (2) init rewrite engine with requested uri
/rails/test/public/dispatch.cgi
[redir#1] (3) applying pattern ‘^/rails/([^/]+)/?(.)$’ to uri
‘/rails/test/public/dispatch.cgi’
[redir#1] (4) RewriteCond: input=’/rails/test/public/dispatch.cgi’
pattern=’!^/rails/([^/]+)/public/’ => not-matched
[redir#1] (1) pass through /rails/test/public/dispatch.cgi
[redir#1] (3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
strip per-dir prefix: C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi -> dispatch.cgi
[redir#1] (3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
applying pattern ‘^$’ to uri ‘dispatch.cgi’
[redir#1] (3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
strip per-dir prefix: C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi -> dispatch.cgi
[redir#1] (3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
applying pattern ‘^([^.]+)$’ to uri ‘dispatch.cgi’
[redir#1] (3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
strip per-dir prefix: C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi -> dispatch.cgi
[redir#1] (3) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
applying pattern '^(.
)$’ to uri ‘dispatch.cgi’
[redir#1] (4) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
RewriteCond: input=‘C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi’ pattern=’!-f’ =>
not-matched
[redir#1] (1) [perdir C:/Program Files/Apache/htdocs/rails/test/public/]
pass through C:/Program
Files/Apache/htdocs/rails/test/public/dispatch.cgi

It looks like the path info is lost somewhere, however the errors I get
seem to indicate that the first five characters get cut off:

/rails/test/something
Routing Error
Recognition failed for “ing”

/rails/test/something/completely_different
Routing Error
Recognition failed for “ing/completely_different”

/rails/test/somethi
Routing Error
Recognition failed for “i”

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