Apache Rewrites in VirtualHost Changing Rails Base URL?

I'm trying to configure my Rails application to handle most requests using Mongrel with a select few (file uploads and other long-running processes) passed through to the CGI dispatcher.

Here is what my Apache configuration (httpd.conf) looks like:

    <virtualhost example.com>     ...     # Long-running processes     RewriteCond %{REQUEST_URI} ^/lorem/ipsum.*$     RewriteRule ^(.*)$ /dispatch.cgi [QSA,L]

    # Redirect all non-static requests to cluster     RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f     RewriteRule ^(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]     SetEnv force-proxy-request-1.0 1     SetEnv proxy-nokeepalive 1     </virtualhost>

What I find is that a request to /lorem/ipsum is properly passed through to the CGI dispatcher, but that request is processed as if it were merely /. As such, it always processes the main page of my application instead of /lorem/ipsum. All the URLs in the source are also prefixed with /lorem/ipsum, including linked media such as stylesheets and javascripts, which makes me think it's treating /lorem/ ipsum as if it were the RewriteBase.

It's probably worth noting that I've tried using CGI from inside the .htaccess configuration, and this never happened. But in order to make my .htaccess file environment-independent, it'd be much easier to keep the rewrites inside httpd.conf (since that's where the proxy redirect is), so each environment can be customized as necessary without some overly elaborate deployment/configuration scheme.

Is there something about my Apache rewrites that is causing Rails to misinterpret the request URL and treat it as / instead of /lorem/ ipsum? Why else might Rails be treating the URL differently in CGI versus Mongrel?