# Subdomain Setup

**URL:** <https://www.ruby-forum.com/t/subdomain-setup/71681>\
**Category:** Rails\
**Created:** [October 10, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/subdomain-setup/71681 "2006-10-10T19:42:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 10, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/subdomain-setup/71681/1 "2006-10-10T19:42:27Z")

</div>

Hi all,

I’m implementing a new site that will need domains like this:  
[newyork.foo.com](http://newyork.foo.com), [chicago.foo.com](http://chicago.foo.com). Each of these domains will be a self  
contained community. Locations is a table in the db. The user will be  
able  
to login to a specific Location and then add content to it. When a user  
visits [newyork.foo.com](http://newyork.foo.com) for example, I need to scope all the content to  
that  
specific location. new locations do not need to be created dynamically.  
Can anyone recommend a good way of setting up this type of environment?  
I’m  
using Apache 2.2

thanks!

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 10, 2006, 7:52pm UTC](https://www.ruby-forum.com/t/subdomain-setup/71681/2 "2006-10-10T19:52:28Z")

</div>

Hello - try  
[http://wiki.rubyonrails.com/rails/pages/HowToUseSubdomainsAsAccountKeys](http://wiki.rubyonrails.com/rails/pages/HowToUseSubdomainsAsAccountKeys)

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 10, 2006, 8:16pm UTC](https://www.ruby-forum.com/t/subdomain-setup/71681/3 "2006-10-10T20:16:33Z")

</div>

This  
[http://redhanded.hobix.com/bits/dynamicVhostsOneLinerForRails.html](http://redhanded.hobix.com/bits/dynamicVhostsOneLinerForRails.html) may  
help you.

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 10, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/subdomain-setup/71681/4 "2006-10-10T21:12:52Z")

</div>

Those are helpful links, thanks. But where my problem differs is that  
the  
subdomain is not user specifc, rather it is group specific. An Account  
belongs to a city and a city name is what is used for the subdomain.

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 11, 2006, 5:06pm UTC](https://www.ruby-forum.com/t/subdomain-setup/71681/5 "2006-10-11T17:06:04Z")

</div>

It’s the same principal. Just get the subdomain use it to find the  
appropriate city, group, cow, spaceship, whatever…

Starr
