Ignore path

Hi.

I'm trying to rewrite a path to a different application with Apache.

My Apache Rewrite rule is

RewriteRule ^/(service)/(.*)$ balancer://myapp_service_cluster%{REQUEST_URI} [P,QSA,L]

My other rewrites for this site work, but the problem (and why I'm asking here and not on an Apache forum) is that I'm curious if it will ever be rewritten correctly, because at the moment, it's passed to myapp, which then tries to find a controller named "service".

Is there any way for myapp to 'ignore' the /service/ path? In routes.rb maybe?

Thanks, Bjørn

Hi.

I'm trying to rewrite a path to a different application with Apache.

My Apache Rewrite rule is

RewriteRule ^/(service)/(.*)$ balancer://myapp_service_cluster% {REQUEST_URI} [P,QSA,L]

My other rewrites for this site work, but the problem (and why I'm asking here and not on an Apache forum) is that I'm curious if it will ever be rewritten correctly, because at the moment, it's passed to myapp, which then tries to find a controller named "service".

Is there any way for myapp to 'ignore' the /service/ path? In routes.rb maybe?

If my memory is correct if you prepend service to you routes then
this will have the desired effect (don't forget to restart your app) i.e. map.connect 'service/:controller/:action/:id'

Fred

Still gets the same error:

Routing Error

no route found to match "/service/" with {:method=>:get}

(same happens without trailing slash)

Thanks, Bjørn

No, because if it gets to myapp, it's too late for it to get to the other app. You need to fix your RewriteRule.

Sure, my initial thought was that I had the wrong rule. After trying a whole set of different rules I just gave up and asked here.

Do you (or does anyone else) have an idea of a rule that would work?

Just to make it clearer, this is how I'd like it to work:

www.myapp.com

points to an Apache server and is rewritten to a load balance cluster (works ok). In addition to that, I'd like a second (and later on a third), seperate rails application to run at

www.myapp.com/service/

and to be rewritten to another cluster.

The reason why I 'need' a new application is that the /service/ application is encoded with Latin1 and connects to a pre-existing Interbase db, whereas the root application is encoded with UTF-8 and connects to MySQL. It's also in part because it seems more maintainable and more secure to have it spread across like that. I.e. if one 'module' goes down, the rest of the site is still operational. To users, the /service/ should appear as an integral part of the site. I could just use subdomains, but it'd be nicer to have everything as paths.

Here's the vhosts file I use (conf\extra\httpd-vhosts.conf):

<VirtualHost *:80>     ServerName myapp.com     ServerAlias www.myapp.com   ServerAlias myapp     DocumentRoot "C:/dev/server/app/myapp/public"

    # ProxyPass / http://localhost:4000/     # ProxyPassReverse / http://localhost:4000     # ProxyPreserveHost on

  <Directory "C:/dev/server/app/myapp/public">     Options FollowSymLinks     AllowOverride None     Order allow,deny     Allow from all   </Directory>

  RewriteEngine On   RewriteCond %{HTTP_HOST} ^myapp.com$ [NC]   RewriteRule ^(.*)$ http://www.myapp.com$1 [R=301,L]   RewriteRule ^/$ /index.html [QSA]   RewriteRule ^([^.]+)$ $1.html [QSA]   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f   RewriteRule ^/(.*)$ balancer://myapp_cluster%{REQUEST_URI} [P,QSA,L]   RewriteRule ^/(service)/(.*)$ balancer://myapp_service_cluster%{REQUEST_URI} [P,QSA,L]

  AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css   BrowserMatch ^Mozilla/4 gzip-only-text/html   BrowserMatch ^Mozilla/4.0[678] no-gzip   BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  ErrorLog logs/myapp_errors_log   CustomLog logs/myapp_log combined </VirtualHost> <Proxy balancer://myapp_cluster>   BalancerMember http://localhost:4000   BalancerMember http://localhost:4001   BalancerMember http://localhost:4002 </Proxy> <Proxy balancer://myapp_service_cluster>   BalancerMember http://localhost:4010   BalancerMember http://localhost:4011   BalancerMember http://localhost:4012 </Proxy>

Thanks, Bjørn