# Ignore path

**URL:** <https://www.ruby-forum.com/t/ignore-path/116101>\
**Category:** Rails\
**Created:** [October 2, 2007, 12:04pm UTC](https://www.ruby-forum.com/t/ignore-path/116101 "2007-10-02T12:04:34Z")\
**Posts on this page:** 5\
**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:04pm UTC](https://www.ruby-forum.com/t/ignore-path/116101/1 "2007-10-02T12:04:34Z")

</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 3, 2007, 2:05am UTC](https://www.ruby-forum.com/t/ignore-path/116101/2 "2007-10-03T02:05:59Z")

</div>

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

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

? Not sure why you’re trying to use mod\_rewrite here.

Your VirtualHost can include something like this:

ProxyPass /service/ balancer://service\_cluster/  
ProxyPassReverse /service/ balancer://service\_cluster/

ProxyPass / balancer://default\_cluster/  
ProxyPassReverse / balancer://default\_cluster/

\<Proxy balancer://default\_cluster\>  
BalancerMember [http://localhost:4000](http://localhost:4000)  
BalancerMember [http://localhost:4001](http://localhost:4001)  
BalancerMember [http://localhost:4002](http://localhost:4002)

\<Proxy balancer://service\_cluster\>  
BalancerMember [http://localhost:4010](http://localhost:4010)  
BalancerMember [http://localhost:4011](http://localhost:4011)  
BalancerMember [http://localhost:4012](http://localhost:4012)

Add:  
ActionController::AbstractRequest.relative\_url\_root = “/service”  
::to your /service/ environment.rb and you should be set.

Or at least it seems to work for me 🙂

## FWIW,

Hassan S. ------------------------ 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 3, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/ignore-path/116101/3 "2007-10-03T12:05:56Z")

</div>

Thanks Hassan. I still get the same error though! 😕  
My vhosts.conf looks like this now:

\<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 / balancer://myapp\_cluster/  
ProxyPassReverse / balancer://myapp\_cluster/

ProxyPass /service/ balancer://myapp\_service\_cluster/  
ProxyPassReverse /service/ balancer://myapp\_service\_cluster/

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

\<Directory “C:/dev/server/app/myapp\_service/public”\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all  
  
  
\<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)

The relative\_url\_root thing was put into the /service/ environment.rb.

About the rewrites, one reason IIRC is to allow Apache to handle the  
static content?  
Whether or not my rewrites actually do that is another question. 😉

I’ve also tried, in the root application public/.htaccess file, to do:

# If you don’t want Rails to look in certain directories,

# use the following rewrite rules so that Apache won’t rewrite certain

requests

# 

# Example:

RewriteCond %{REQUEST\_URI} ^/service.\*  
RewriteRule .\* - [L]

but no go. I’ve also tried doing that within the vhosts.conf file.

Thanks,  
Bjørn

On Oct 3, 2:05 am, “Hassan S.” [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 3, 2007, 6:32pm UTC](https://www.ruby-forum.com/t/ignore-path/116101/4 "2007-10-03T18:32:05Z")

</div>

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

> Thanks Hassan. I still get the same error though! 😕  
> My vhosts.conf looks like this now:

> ```
> ProxyPass / balancer://myapp_cluster/
> ProxyPassReverse / balancer://myapp_cluster/
> 
> ProxyPass /service/ balancer://myapp_service_cluster/
> ProxyPassReverse /service/ balancer://myapp_service_cluster/
> 
> ```

I think the order of the above is significant – the more specific  
reference should come first, because anything will match to /.

Have you looked at your mongrel logs? I’m betting the Routing  
Error is coming from a mongrel in your my\_app cluster, /not/  
the myapp\_service\_cluster.

> 

BTW, I think the Proxy elements should be inside the VirtualHost  
element, though that’s probably not the cause of this problem…

> About the rewrites, one reason IIRC is to allow Apache to handle the  
> static content?

Ah, well, that’s totally different. I never do apps with enough static  
content to bother 🙂

But I would try swapping the ProxyPass stuff first…

## HTH,

Hassan S. ------------------------ 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 4, 2007, 10:41am UTC](https://www.ruby-forum.com/t/ignore-path/116101/5 "2007-10-04T10:41:17Z")

</div>

Well that helped. =)  
Probably because of the order like you said.

The routing error would’ve had to be in the root app since I haven’t  
had a /service/ app running most of the time. 😉

Adding the rewrites again underneath, it reverts back to the old  
behaviour, but this isn’t being deployed for another couple of months  
so I think I’ll drop it for now.

Thanks again!,  
Bjørn

On Oct 3, 6:31 pm, “Hassan S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
