# Regular expression and routing

**URL:** <https://www.ruby-forum.com/t/regular-expression-and-routing/91142>\
**Category:** Rails\
**Created:** [April 5, 2007, 2:36am UTC](https://www.ruby-forum.com/t/regular-expression-and-routing/91142 "2007-04-05T02:36:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehudros](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ec8ea/32.png) [@ehudros](https://www.ruby-forum.com/u/ehudros)\
**Post date:** [April 5, 2007, 2:36am UTC](https://www.ruby-forum.com/t/regular-expression-and-routing/91142/1 "2007-04-05T02:36:10Z")

</div>

Hi everyone,  
I’m struggling to get my routing as I want it…  
I want to create a regular expression that will only allow the  
controller/action to be executed if the subdomain is not ‘www’.

I have soemthing like this:  
map.connect ‘:controller/:action/:id’ , :conditions =\> { :subdomain =\>  
/(!www)/}

only it seems to block everything (including  
[subdomain.localhost.com/blog](http://subdomain.localhost.com/blog))…  
What’s the right way to do it?

I’m not even sure that’s what I need at all 🙂  
I’m trying to figure out the right way to handle a site with multiple  
subdomains (user profiles) so that some controllers are only avaialable  
if you access them through a subdomain. has someone managed to figure it  
out and can shed some light?

Thanks!  
ehud

---

<div class="post-metadata">

**Author:** ![ehudros](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ec8ea/32.png) [@ehudros](https://www.ruby-forum.com/u/ehudros)\
**Post date:** [April 5, 2007, 2:38am UTC](https://www.ruby-forum.com/t/regular-expression-and-routing/91142/2 "2007-04-05T02:38:04Z")

</div>

Ehud R. wrote:

> Hi everyone,  
> I’m struggling to get my routing as I want it…  
> I want to create a regular expression that will only allow the  
> controller/action to be executed if the subdomain is not ‘www’.
> 
> I have soemthing like this:  
> map.connect ‘:controller/:action/:id’ , :conditions =\> { :subdomain =\>  
> /(!www)/}
> 
> only it seems to block everything (including  
> [subdomain.localhost.com/blog](http://subdomain.localhost.com/blog))…  
> What’s the right way to do it?
> 
> I’m not even sure that’s what I need at all 🙂  
> I’m trying to figure out the right way to handle a site with multiple  
> subdomains (user profiles) so that some controllers are only avaialable  
> if you access them through a subdomain. has someone managed to figure it  
> out and can shed some light?
> 
> Thanks!  
> ehud

What i’m looking for is kind of like what’s described in the groovie  
manual here:  
[http://routes.groovie.org/manual.html#sub-domain-support](http://routes.groovie.org/manual.html#sub-domain-support)

does something like this exist in rails?
