title: htaccess redirect all subdomains + www to domain with cname, vhosts and htaccess
body: <p>I have a rather simple problem for someone who knows, I just cant find the answer that I need. I have moved to vps and try to configure vm by myself. I need redirects:</p>
  
  <ol>
  <li>domain.com - default</li>
  <li>www.domain.com -> domain.com</li>
  <li>*.domain.com -> domain.com</li>
  </ol>
  
  <p>I`ve already done .htaccess for www -> non-www, so I have:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  </code></pre>
  
  <p>Added A and CNAME:</p>
  
  <ul>
  <li>www - @</li>
  <li>* - @</li>
  </ul>
  
  <p>Added virtualhost</p>
  
  <ul>
  <li>ServerAlias www.domain.com *.domain.com</li>
  </ul>
  
  <p>Am I doing right (CNAME, vhost, .htaccess) or it can me done simplier?</p>
  
  <p>Can you please help me redirect *.domain.com -> domain.com (guess in .htaccess) ?</p>