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.

I created a DNS record in co.cc to make it point to x10hosting account. So I have like <mydomain>.co.cc - A - <x10 ip>

Its working properly. Now problem is I have already mentioned name like blog.<mydomain>.co.cc in my previous resumes which I cannot change. So is it possible to redirect sub-domain request to main domain using DNS record.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

You can add a CNAME, but it would not suffice.

This way you only tell browsers that the IP of your blog is the same as the one pointed by your domain DNS record:

blog.dom.tld -> dom.tld -> <your.ip>

If your HTTP server does not implements Vhosts (and I suppose it does as you are in a shared server :), you would had done.

As your server is a Vhost, you have to instruct it to properly handle both blog.dom.tld and dom.tld as the same vhost. You can achieve this behavior using ServerAlias apache directive, for example

EDIT:

don't know your host, but from their forum it seems you can login and do it by hand.

share|improve this answer
    
Where can I make those settings , I have control panel 11 on x10hosting.com –  Xinus Oct 16 '09 at 17:02
    
You need to add a subdomain on the control panel, if they'll let you do that. –  Jaykul Oct 16 '09 at 17:06
    
Thanks.. it worked :) ... But why www was working using CNAME record? OR is it by default provided by x10hosting ? –  Xinus Oct 16 '09 at 17:13
    
I suppose the default env of x10 already handle in the same vhost both domain and www.domain, as it is quite usual that the are the same :) –  AlberT Oct 16 '09 at 17:20
    
-1 because adding the CNAME has side-effects (aliasing blog.mydomain.example to mydomain.example: that will inherit MX, NS etc records). Good practice is to add address records (A and AAAA). –  bortzmeyer May 31 '10 at 7:16
show 1 more comment

as already said, dns do not do redirection.

dns only resolving name to ip.

if you're using apache server, just point the domain to your server ip and you can use .htaccess for redirection.

share|improve this answer
    
Correct. Mod_rewrite in your Apache config or .htaccess will allow very powerful redirection and URL rewriting. –  Martijn Heemels Oct 17 '09 at 14:17
add comment

DNS doesn't really do redirection like this. Usually you have to point both domains at a web server setup virtual hosts for both domains, and create a rule in in the virtual host to send a redirect.

If you look around there are free/cheap services (e.g. dyndns) that will do the redirection for you. Basically you point the name that you want redirected at them, then tell them what URL to redirect too.

share|improve this answer
    
Actually I did tried pointing "www" CNAME record to main domain which works...but similar settings for "blog" does not work ? –  Xinus Oct 16 '09 at 16:53
1  
my answer explains why, and how you can do it work –  AlberT Oct 16 '09 at 16:56
add comment

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.