# Redirecting root to mongrel prefix

**URL:** <https://www.ruby-forum.com/t/redirecting-root-to-mongrel-prefix/158836>\
**Category:** Rails\
**Created:** [January 28, 2009, 4:22pm UTC](https://www.ruby-forum.com/t/redirecting-root-to-mongrel-prefix/158836 "2009-01-28T16:22:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jemminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@jemminger](https://www.ruby-forum.com/u/jemminger)\
**Post date:** [January 28, 2009, 4:22pm UTC](https://www.ruby-forum.com/t/redirecting-root-to-mongrel-prefix/158836/1 "2009-01-28T16:22:09Z")

</div>

Mongrel can be started with a prefix e.g.

mongrel\_rails start -p 3000 --prefix /foobar

So that all of the app’s URLs are prefixed, e.g.

[http://localhost:3000/foobar](http://localhost:3000/foobar)  
[http://localhost:3000/foobar/posts](http://localhost:3000/foobar/posts)  
[http://localhost:3000/foobar/posts/1](http://localhost:3000/foobar/posts/1)

The problem is that if you hit just the root ( [http://localhost:3000/](http://localhost:3000/)  
) then mongrel responds with “NOT FOUND”.

I tried adding an index.html to RAILS\_ROOT/public that redirects to /  
foobar, but this results in an infinite loop.

Does anyone know how to get requests to the root to redirect to the  
prefix?

---

<div class="post-metadata">

**Author:** ![jemminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@jemminger](https://www.ruby-forum.com/u/jemminger)\
**Post date:** [January 28, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/redirecting-root-to-mongrel-prefix/158836/2 "2009-01-28T17:50:58Z")

</div>

I think you are missing a piece of the puzzle, Apache and  
mod\_proxy…

You would never run multiple app roots unless you had multiple apps  
and or a php app on / and a rails app on /app1…

If you want multiple apps running on your dev env just start them with  
-p 3001 -p 3002 … ? much easier… but I guess that depends on what  
you are trying to do …

---

<div class="post-metadata">

**Author:** ![jemminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@jemminger](https://www.ruby-forum.com/u/jemminger)\
**Post date:** [January 28, 2009, 6:13pm UTC](https://www.ruby-forum.com/t/redirecting-root-to-mongrel-prefix/158836/3 "2009-01-28T18:13:52Z")

</div>

On Jan 28, 11:50 am, Freddy A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I think you are missing a piece of the puzzle, Apache and  
> mod\_proxy…

Yes, this is running behind Apache. We have a Java app that runs at  
[http://java.ourdomain.com/foo](http://java.ourdomain.com/foo)

We have Apache proxy forwarding [http://java.ourdomain.com/bar](http://java.ourdomain.com/bar) to  
[http://rails.ourdomain.com/bar](http://rails.ourdomain.com/bar)

…so that ajax calls aren’t cross-domain to the java app.

The issue with redirecting the root requests to the prefixed URL is  
more a matter of convenience, just so someone doesn’t see “NOT FOUND”  
if they happen to hit the root URL.
