Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Suppose I have a portal www.mysite.com which has subdomains like user1.mysite.com, user2.mysite.com and suppose a user, say user1 has a domain - www.user1.com.

Can user1 create a subdomain - mysite.user1.com which will point to the existing user1.mysite.com?

I know I can redirect it but that's not what I am looking for.

Explaining my problem a bit more.

i have a rails app running on apache and passenger, on a machine with ip say xxx.xxx.xxx.xxx, to which www.mycustomservice.com is pointed to.

suppose i am creating a new subdomain called client1.mycustomservice.com which will serve a couple of static pages from the same rails app, can i do something so that the requests to customservice.client1.com is served from this same app ?

share|improve this question

4 Answers 4

You can point it at that address or use CNAME records (or DNAME, but they don't behave like you would normally want them to). Domains can point wherever; something being a subdomain really has no bearing except on where you look to resolve it.

share|improve this answer
    
Thank you falcon, i have edited my question to explain a bit more about my problem. –  Krishnaprasad Varma May 7 '12 at 4:11

Yes, you can. A domain can be pointed to any IP address, regardless of what else may be pointing to the same address.

share|improve this answer

If you want to do this with least effort, then you just need to match on 'user1' (the string common to both domains). But you need to plan for how to deal with users called 'www' and 'com'.

e.g.

RewriteEngine On
RewriteCond %{HTTP_HOST} \.user1\..
RewriteRule ^/(.*)$  /home/user1/www/$1 [L]

And set the virtualhost as '*:80'

share|improve this answer
    
thank you for this snippet . hope it helps one or the other way –  Krishnaprasad Varma May 7 '12 at 4:24

I think you have two issues here:

1) Point the client1.mycustomservice.com to the same ip of www.mycustomservice.com or with a CNAME

2) Setup a VirtualHost in Apache to server the same rails app for the two domains names. Just like this:

ServerName www.mycustomservice.com ServerAlias client1.mycustomservice.com

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.