Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have moved a lot of people off one of my servers. Each person had an account using subdomains so What I would like to do is set it up so ANY subdomain accessed on the domain is automatically forwarded to the correct subdomain on domain.

So would go to

I'm not that up on DNS so I don't really know what I am looking for.

I have set up an A Record for * pointing to the IP address of thinking that "may" work but it hasn't.

EDIT: I have now set up a * CNAME record pointing to I am waiting to see if it works.

share|improve this question
A records are direct pointers from hostname to IP address, try it with a CNAME record, which is an alias pointer where you can do something like you are already trying. – Tim Dec 9 '11 at 14:08
@Tim - Made the change, will wait for propagation and see how it goes. Thanks. – webnoob Dec 9 '11 at 14:11
Just to clarify I have done this correctly, I have added a record against where subdomain is *, type is CNAME and domain is That correct? – webnoob Dec 9 '11 at 14:27
Are you running other services beside HTTP? If not, then what web server are you using? – Mircea Vutcovici Dec 9 '11 at 15:23
@Mircea - Sorry I am not sure I follow what you mean. I am running Linux Centos with CPanel / WHM. It is only used as a web server if that is what you mean. – webnoob Dec 9 '11 at 15:27

2 Answers 2

up vote 2 down vote accepted

If I understand correctly, you want to:

* > *

And have the * host specification match up correctly.

If yes, then I suggest creating * and then using Rewrite Rules to do a permanment redirect to the domain.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ([a-z0-9-]+) [NC]
RewriteRule ^(.*)$$1 [R=301]

This is just a stab at the rewrite rule - it has not been tested. The idea is to catch the sub domain name in back reference and then pass it into your new URL.

share|improve this answer
Ok, thats a sound idea. Can you just clarify what you mean about "create a *". Do you mean host somewhere and just rewrite everthing then forward? – webnoob Dec 9 '11 at 17:37
* is just a wild card domain name. This is required so the same domain will answer for all sub domains. – jeffatrackaid Dec 11 '11 at 15:22

I don't believe that what you want to do can be done using DNS alone. I'd setup a virtual host for * which does a 301 (permanant) redirect to the correct url.

share|improve this answer
Do you know of any documentation / tutorials on doing this? All this stuff is rather new to me. – webnoob Dec 9 '11 at 17:09

Your Answer


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.