title: htaccess automatically detect domain name
body: <p>I made script that automatically create subdomain.</p>
  
  <p>the htaccess working fine,
  but the problem is, <em>i need to manually change domain name when install on new domain</em>.</p>
  
  <p>I want to automatically detect domain name in htaccess, is that possible?</p>
  
  <p>so when adding in another server or new domain, <em>no need to change the domain root htaccess again</em>.</p>
  
  <p>domain root htaccess is:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9][-a-z0-9]+)\.mydomain\.com(:80)?$ [NC]
  RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
  </code></pre>
  
  <p>i try to change automatically get from <code>%{HTTP_HOST}</code></p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9][-a-z0-9]+)\.%{HTTP_HOST}(:80)?$ [NC]
  RewriteCond %{HTTP_HOST} !^www\.%{HTTP_HOST}
  </code></pre>
  
  <p>the problem is on <code>%{HTTP_HOST}</code>,
  how to get/match current domain in current url with htaccess?</p>
  
  <p>maybe need to get <strong>domain name as variable</strong>.</p>
  
  <p>Thank you </p>