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

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 you can redirect a specific subdomain to another domain and I need something but less specific. I need some way of redirecting every subdomain to another domain and Im not sure if this is actually possible. I was wanting to do this directly inside the apache config fileinstead of with htaccess. I am using debain6.

Any suggestions would be much appreciated.

share|improve this question
See this also You need set up DNS record for wildcard subdomain. *.subdomain.tld. IN A – Guntis Apr 18 '13 at 8:49

To redirect all sub domains to another domain:

<VirtualHost *:80>
    ServerAlias *
    Redirect 301 /

You could also simply create a wildcard alias for the target domain. The advantage of this is that it would allow you to serve cookies from the requested domain. This will not change the address bar in the browser like the first example.

<VirtualHost *:80>
    ServerAlias *
    DocumentRoot /var/www/
share|improve this answer
A 302 redirect is better, unpicking a 301 if you want to use a previously redirected subdomain is really a pain. – Iain Apr 18 '13 at 9:12

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.