# SubDomain Queries

**URL:** <https://www.ruby-forum.com/t/subdomain-queries/169087>\
**Category:** Rails\
**Created:** [May 29, 2009, 8:29am UTC](https://www.ruby-forum.com/t/subdomain-queries/169087 "2009-05-29T08:29:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [May 29, 2009, 8:29am UTC](https://www.ruby-forum.com/t/subdomain-queries/169087/1 "2009-05-29T08:29:04Z")

</div>

Hi,

I have a requirement in my rails application where i need to provide  
access  
to a blog from another domain.  
e.g: [blog.company.com](http://blog.company.com) should point to my app’s blog\_controller’s show  
action. Is this possible.

& if it is possible, will the user see:

1. [blog.company.com/blog/some-blog](http://blog.company.com/blog/some-blog)
2. [myapp.com/blog/some-blog](http://myapp.com/blog/some-blog)

I read a lot about Subdomain\_fu. But i think it can only emulate  
subdomains  
in my own app. like ([blog.myapp.com](http://blog.myapp.com)) or ([company.blog.myapp.com](http://company.blog.myapp.com)).

I really need help on this. Any pointers or suggestions are always  
welcome.

Regards

–  
Sahil

---

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [May 29, 2009, 4:08pm UTC](https://www.ruby-forum.com/t/subdomain-queries/169087/2 "2009-05-29T16:08:17Z")

</div>

Hi Sahil,

If someone types in [blog.company.com](http://blog.company.com), you will need access to the  
server on which that domain resides in order to redirect it to your  
app, it has nothing to do with how you structure your application.

If you setup a redirect, then the user will see [yourapp.com/blog/:id](http://yourapp.com/blog/:id)  
unless you reconfigure the routes in routes.rb. The alternative so  
that the user sees [blog.company.com](http://blog.company.com) is to frame your site on the  
[company.com](http://company.com) website although this is considered slightly 2001 and not  
really the done thing.

Robin

---

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [May 29, 2009, 5:53pm UTC](https://www.ruby-forum.com/t/subdomain-queries/169087/3 "2009-05-29T17:53:15Z")

</div>

Apache and mod\_rewrite will be your friend. I would also setup a  
virtualhost for the [blog.company.com](http://blog.company.com)

But are you saying that you have [mycompany.com](http://mycompany.com) which is a rails app  
and you want your [blog.othercompany.com](http://blog.othercompany.com) to use your blog controller?

Or when people go on your blog they should see [blog.mycompany.com](http://blog.mycompany.com) in  
the browser?

---

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [May 30, 2009, 5:53pm UTC](https://www.ruby-forum.com/t/subdomain-queries/169087/4 "2009-05-30T17:53:29Z")

</div>

On Sat, May 30, 2009 at 8:43 AM, sahil [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> so, when a user goes to [blog.company.com](http://blog.company.com), he should see contents of  
> the the rails\_app, but the domain part of the url should not change.

? So, maybe I’m not understanding the issue.

Create a virtual host for [blog.company.com](http://blog.company.com) and install your blog app  
there. No redirection, no url change.

Yes?

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [May 30, 2009, 5:44pm UTC](https://www.ruby-forum.com/t/subdomain-queries/169087/5 "2009-05-30T17:44:38Z")

</div>

On May 29, 7:07 pm, Robin F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> really the done thing.  
> No, actually i am not looking for the redirection thing. What i want  
> is the CNAME Record change of [blog.company.com](http://blog.company.com). I have access to this  
> and the other domain.  
> so, when a user goes to [blog.company.com](http://blog.company.com), he should see contents of  
> the the rails\_app, but the domain part of the url should not change.

Regards

Sahil

---

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [June 1, 2009, 7:52am UTC](https://www.ruby-forum.com/t/subdomain-queries/169087/6 "2009-06-01T07:52:23Z")

</div>

On May 30, 8:52 pm, Hassan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Sat, May 30, 2009 at 8:43 AM, sahil [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > so, when a user goes to [blog.company.com](http://blog.company.com), he should see contents of  
> > the the rails\_app, but the domain part of the url should not change.
> 
> ? So, maybe I’m not understanding the issue.
> 
> Create a virtual host for [blog.company.com](http://blog.company.com) and install your blog app  
> there. No redirection, no url change.
> 
> Yes?

Yes, i think you are right.

Thanks.
