Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know this may seem like a duplicate, but I am unable to find a solution. Is it possible to setup wildcard subdomains with htaccess?

I have an example of

http://test.domain.ca I need to forward to http://www.domain.ca

I don't have specific 'sub-domains'. so I would need a form of a wildcard. Is this possible to do through HTACCESS?

Any help is appreciated.

share|improve this question
up vote 1 down vote accepted

Short answer: No, it's not possible to setup wildcard subdomains with .htaccess.

To achieve what you want to do, you need to have a wildcard record in your DNS zone file, because your nameserver is where the subdomains are looked up. Also, many hosting companies will not allow you to add a wildcard record, so you'll have to check with them.

share|improve this answer

Do you actually have a * wildcard record in your DNS zone file? If yes then all you need to do is add an A record into the zone file and point it to the IP hosting your domain.ca now all connections to that specific sub domain will go to www.domain.com while the other wildcard subdomains will go some place else.

Or in cPanel you would simply create your test subdomain.

share|improve this answer

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.