I'm trying to use mod_rewrite to proxy requests from my main Apache server to a Mongrel server running my Ruby on Rails application.
My main server is http://lab.mydomain.com and I want users to be able to access the application at http://lab.mydomain.com/myapp/, but have those requests transparently proxied to http://localhost:8080/ (the mongrel server running on the same machine as Apache).
At the moment my rewrite rules look like this (in .htaccess in the /myapp/ dir):
- Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myapp/
RewriteRule (.*) http://localhost:8080/$1 [P]
</IfModule>
However, there is a problem. URLs in the application are all absolute and start with "/", because in the testing phase the application ran out of the root directory. This means that the index page of the application will load, but stuff like images and stylesheets won't, because they are using URLs like "/images/myimage.jpg" and "/stylesheets/style.css".
My question is: is there a way I can address this using mod_rewrite, or should I instead look to correct those URLs in the application to use relative paths instead (via some Rails configuration, rather than mod_rewrite)? I'm thinking this may be beyond the scope of mod_rewrite since it's the application that is causing stuff like http://lab.mydomain.com/images/myimage.jpg to be requested rather than http://lab.mydomain.com/myapp/images/myimage.jpg, which is being rewritten.
Any help would be hugely appreciated. Thanks for reading!
Biggs