Using mod_rewrite instead of mod_alias to mask rails directory

Hi all,

I’m experiencing some google groups strangeness (namely my post from yesterday being sent to /dev/blackhole - so apologies if this does show up twice.

I’m trying to use mod_rewrite to mask the location of my rails

directory. My virtual host set up is as follows:

/httpdocs (docroot) /rails (railsroot)

so browsing to mydomain.com/rails/controller/action actually goes to the railsroot directory above . This all works beautifully (using Apache 2 / mod_fcgid btw - which is absolutely excellent!)

What I want is for people to be able to hit

mydomain.com/controller/action. One obvious way of achieving this is with mod_alias, but as my site is managed with Plesk, making vhost

level conf changes is a bit tricky (and a real maintenance hassle) so I’d prefer to accomplish this with a .htaccess level mod_rewrite rule.

What I’ve currently got is an htaccess file in httpdocs:

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/rails/ RewriteRule ^(.*)$ /rails/$1 [L]

Which is fairly straightforward. The crazy thing is that although this successfully redirects “/” to the shortcut rails route, every other URL

also gets directed there (eg: /news, /contact all end up at / in the rails app.) Full controller/action/param calls get a 404.

I’ve tried a couple of variations on this rule:

RewriteRule ^(.*)$ /rails/public/$1 [L]

RewriteRule ^(.*)$ /rails%{REQUEST_URI} [L]

Both of which exhibit the same behaviour.

The following rule results in a 404: RewriteRule ^/(.*)$ /rails/$1 [L]

(note the addition of the / to the match)

Obvioulsy if I specificy a 30x redirect with [R] it works. I’ve checked the rails log, and the correct url is being called.

In an act of voodooish desperation I even tried using the RewriteBase directive in the rails/public/.htacess.

Can anyone think of anything obvious (or even slightly less obvious) that I’m doing wrong?

Thanks!

Corin

Has anyone got any insight into my above problem?

It'd be greatly appreciated.

Thanks,

Corin