# Custom account subdomains with Rails 3

**URL:** <https://www.ruby-forum.com/t/custom-account-subdomains-with-rails-3/190643>\
**Category:** Rails\
**Created:** [June 24, 2010, 12:29pm UTC](https://www.ruby-forum.com/t/custom-account-subdomains-with-rails-3/190643 "2010-06-24T12:29:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piotr\_Sarnacki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/94ad74/32.png) [@Piotr\_Sarnacki](https://www.ruby-forum.com/u/Piotr_Sarnacki)\
**Post date:** [June 24, 2010, 12:29pm UTC](https://www.ruby-forum.com/t/custom-account-subdomains-with-rails-3/190643/1 "2010-06-24T12:29:49Z")

</div>

Hi,

I needed to handle custom account subdomains with Rails and I wrote a  
simple rack middleware for that [http://github.com/drogus/rack-subdomain](http://github.com/drogus/rack-subdomain).  
It works by mapping any subdomain to given PATH. For example when user  
hits [drogus.example.org/account](http://drogus.example.org/account) and mapping is /users/:subdomain, it  
will map the request to [example.org/users/drogus/account](http://example.org/users/drogus/account)

I accomplished it with rack middleware, cause I wanted to have this  
mechanism also for Rails 2.x.

The thing is, I don’t want to duplicate stuff that’s already in  
router, so here is my question: is there any way to do such mapping  
with Rails 3 router? Or maybe a better way to handle custom account  
subdomains?

Cheers,

Peter

---

<div class="post-metadata">

**Author:** ![Piotr\_Sarnacki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/94ad74/32.png) [@Piotr\_Sarnacki](https://www.ruby-forum.com/u/Piotr_Sarnacki)\
**Post date:** [June 25, 2010, 1:43pm UTC](https://www.ruby-forum.com/t/custom-account-subdomains-with-rails-3/190643/2 "2010-06-25T13:43:20Z")

</div>

Have a look at this article:  
[http://www.taylorluk.com/2009/08/hey-pac-man-sup-subdomains](http://www.taylorluk.com/2009/08/hey-pac-man-sup-subdomains)
