# How to set a root URL?

**URL:** <https://www.ruby-forum.com/t/how-to-set-a-root-url/159856>\
**Category:** Rails\
**Created:** [February 9, 2009, 1:57pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856 "2009-02-09T13:57:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Pierre\_L](https://www.ruby-forum.com/u/Pierre_L)\
**Post date:** [February 9, 2009, 1:57pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856/1 "2009-02-09T13:57:58Z")

</div>

Hello,

My server installation of RoR is working but I still have a problem  
with routes. I would like the root URL of my site to be some thing  
like [mydomain.com/mysite/](http://mydomain.com/mysite/) . But this is not working since Rails  
include the ‘/mysite/’ in his routing. Of course, if in all  
connections in routes.rb I add ‘/mysite’, all is working, but is there  
another way to tell Rails that my root URL is not ‘/’ ?

Thank you for all,  
Pierre L.

---

<div class="post-metadata">

**Author:** ![Pierre\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Pierre\_L](https://www.ruby-forum.com/u/Pierre_L)\
**Post date:** [February 9, 2009, 2:00pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856/2 "2009-02-09T14:00:20Z")

</div>

AFIK, no, there isn’t.

What you could do, if you really need something like this (I can’t see  
a reason…) is, at the “root\_path” redirect to this URL that you want  
to be your root.

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

---

<div class="post-metadata">

**Author:** ![Pierre\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Pierre\_L](https://www.ruby-forum.com/u/Pierre_L)\
**Post date:** [February 9, 2009, 3:18pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856/3 "2009-02-09T15:18:47Z")

</div>

Is your app fronted by Apache?

–  
James M.

---

<div class="post-metadata">

**Author:** ![Pierre\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Pierre\_L](https://www.ruby-forum.com/u/Pierre_L)\
**Post date:** [February 9, 2009, 3:29pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856/4 "2009-02-09T15:29:57Z")

</div>

In fact, my site is still in development, I don’t want to put it on  
the root of my domain, but in a directory.  
I think I miss something simple because I’ve done tests few months ago  
and all was ok.

On 9 fév, 13:59, Maurício Linhares [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Pierre\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Pierre\_L](https://www.ruby-forum.com/u/Pierre_L)\
**Post date:** [February 9, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856/5 "2009-02-09T15:25:15Z")

</div>

Yes it is ! Is there a solution with the htaccess ?

---

<div class="post-metadata">

**Author:** ![Pierre\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Pierre\_L](https://www.ruby-forum.com/u/Pierre_L)\
**Post date:** [February 9, 2009, 6:57pm UTC](https://www.ruby-forum.com/t/how-to-set-a-root-url/159856/6 "2009-02-09T18:57:48Z")

</div>

I’ve found : all one have to do it to put  
config.action\_controller.relative\_url\_root = ‘/yourpath’  
in the config file.
