# Ignore path

**URL:** <https://www.ruby-forum.com/t/ignore-path/116102>\
**Category:** Rails\
**Created:** [October 2, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/ignore-path/116102 "2007-10-02T12:05:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@prism](https://www.ruby-forum.com/u/prism)\
**Post date:** [October 2, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/ignore-path/116102/1 "2007-10-02T12:05:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![prism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@prism](https://www.ruby-forum.com/u/prism)\
**Post date:** [October 2, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/ignore-path/116102/2 "2007-10-02T12:19:11Z")

</div>

On 2 Oct 2007, at 11:04, prism wrote:

> 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

---

<div class="post-metadata">

**Author:** ![prism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@prism](https://www.ruby-forum.com/u/prism)\
**Post date:** [October 2, 2007, 1:02pm UTC](https://www.ruby-forum.com/t/ignore-path/116102/3 "2007-10-02T13:02:34Z")

</div>

Still gets the same error:

Routing Error

no route found to match “/service/” with {:method=\>:get}

(same happens without trailing slash)

Thanks,  
Bjørn

On Oct 2, 12:18 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![prism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@prism](https://www.ruby-forum.com/u/prism)\
**Post date:** [October 2, 2007, 10:06pm UTC](https://www.ruby-forum.com/t/ignore-path/116102/4 "2007-10-02T22:06:00Z")

</div>

On 10/2/07, prism [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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?

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.

---

<div class="post-metadata">

**Author:** ![prism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@prism](https://www.ruby-forum.com/u/prism)\
**Post date:** [October 2, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/ignore-path/116102/5 "2007-10-02T22:29:26Z")

</div>

Sure, my initial thought was that the rule was broken.  
But I tried several different ones before just giving up and asking  
here. Do you (or does anyone) have an idea of a rule that could work?

In any case, just to be clear, this is how I’d like it to work:

> **[应用宝官网-全网最新最热手机应用游戏下载](https://sj.qq.com)**
>
> 应用宝是腾讯旗下官方手机app应用商店，致力于为您提供海量、优质、安全、最新的安卓应用游戏下载！

points to an Apache server and is rewritten to a load balance cluster  
(and this does work, rewrite and all).  
In addition to that, I’d like a second (and later on a third),  
seperate rails application to run at

> **[应用宝官网-全网最新最热手机应用游戏下载](https://sj.qq.com)**
>
> 应用宝是腾讯旗下官方手机app应用商店，致力于为您提供海量、优质、安全、最新的安卓应用游戏下载！

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.  
/service/ is closely related to the root application, with the same  
basic layout for the view, and I’d like it to appear as an integral  
part of the site. I can always use subdomains, but I’d rather not.

Here’s the contents of my vhost when it works fine, before adding  
anything to do with the /service/ rewrite and cluster:

\<VirtualHost \*:80\>  
ServerName [myapp.com](http://myapp.com)  
ServerAlias [www.myapp.com](http://www.myapp.com)  
ServerAlias myapp  
DocumentRoot “C:/dev/server/myapp/public”

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

```

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

RewriteEngine On  
RewriteCond %{HTTP\_HOST} ^vmyapp.com$ [NC]  
RewriteRule ^(._)$ [http://www.myapp.com$1](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]

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  
  
\<Proxy balancer://myapp\_cluster\>  
BalancerMember [http://localhost:4000](http://localhost:4000)  
BalancerMember [http://localhost:4001](http://localhost:4001)  
BalancerMember [http://localhost:4002](http://localhost:4002)

Thanks,

---

<div class="post-metadata">

**Author:** ![prism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@prism](https://www.ruby-forum.com/u/prism)\
**Post date:** [October 2, 2007, 11:57pm UTC](https://www.ruby-forum.com/t/ignore-path/116102/6 "2007-10-02T23:57:18Z")

</div>

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:

> **[应用宝官网-全网最新最热手机应用游戏下载](https://sj.qq.com)**
>
> 应用宝是腾讯旗下官方手机app应用商店，致力于为您提供海量、优质、安全、最新的安卓应用游戏下载！

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

> **[应用宝官网-全网最新最热手机应用游戏下载](https://sj.qq.com)**
>
> 应用宝是腾讯旗下官方手机app应用商店，致力于为您提供海量、优质、安全、最新的安卓应用游戏下载！

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](http://myapp.com)  
ServerAlias [www.myapp.com](http://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

RewriteEngine On  
RewriteCond %{HTTP\_HOST} ^myapp.com$ [NC]  
RewriteRule ^(._)$ [http://www.myapp.com$1](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  
  
\<Proxy balancer://myapp\_cluster\>  
BalancerMember [http://localhost:4000](http://localhost:4000)  
BalancerMember [http://localhost:4001](http://localhost:4001)  
BalancerMember [http://localhost:4002](http://localhost:4002)  
  
\<Proxy balancer://myapp\_service\_cluster\>  
BalancerMember [http://localhost:4010](http://localhost:4010)  
BalancerMember [http://localhost:4011](http://localhost:4011)  
BalancerMember [http://localhost:4012](http://localhost:4012)

Thanks,
