title: How do I redirect subdomains that do not exist?
body: <p>I am trying to redirect using .htaccess in the following fashion. I am not all that familiar with .htaccess, so I'm not sure it can be done. Also, I don't know if how I am intending to do it follows best practices for SEO.</p>
  
  <pre><code>www.domain.com                &gt; domain.com 301
  
  ks.domain.com                 &gt; kansas.domain.com 301
  
  ia.domain.com                 &gt; iowa.domain.com 301
  
  domain.com/sites              &gt; domain.com 301
  
  domain.com/sites/iowa         &gt; iowa.domain.com 301
  
  nonexistent.domain.com        &gt; domain.com 302
  
  domain.com/sites/nonexistent  &gt; domain.com 302
  </code></pre>
  
  <p>My biggest question is if I can detect a nonexistent subdomain and redirect. I would love to see how all of the above is accomplished.</p>