title: apply subdomain mapping to an addon domain in Hostgator
body: <p>I have 2 domain names, both hosted on hostgator  (the unlimited domain baby plan)<br>
  1. foo.com (This was the first domain to be registered on HG)<br>
  2. bar.com (I added this as an addon domain in HG)</p>
  
  <p>The directory structure has <code>/public_html/</code> which keeps all of the files and subdirs for foo.com</p>
  
  <p><code>/public_html/</code> has a subdir called <code>bar</code> (i.e. <code>public_html/bar/</code>) which keeps all of the files for bar.com. This was set up by HG during the addon domain process. So files for bar.com would show up like this: <code>/public_html/bar/process.php</code></p>
  
  <p>I want this:<br>
  <code>sss.bar.com/fff</code> -> <code>bar.com/process.php?sub=sss&amp;file=fff</code><br>
  But I'm getting lookup failures.</p>
  
  <p>This is what I tried: (this file is <code>/public_html/bar/.htaccess</code> - there is a separate .htaccess in the parent dir for foo.com, it has one unrelated rule)</p>
  
  <pre><code>RewriteEngine On
  
  # Parse the subdomain as a variable we can access in PHP, and
  # run the main process.php script
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{HTTP_HOST}        !^www
  RewriteCond %{HTTP_HOST}         ^([^\.]+)\.([^\.]+)\.([^\.]+)$
  RewriteRule ^(.*)$ /process.php?sub=%1
  
  # Map all requests to the 'path' get variable in process.php
  RewriteRule ^process\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /process.php?file=$1 [L,QSA] 
  </code></pre>
  
  <p>Tests:<br>
  1. <code>bar.com/myFile</code> -> generates a GET parm in process.php of [file]=>myFile - good.<br>
  2. <code>test.bar.com/myFile</code> does not work.</p>
  
  <p>The error is: </p>
  
  <blockquote>
    <p>The server at test.bar.com can't be found, because
    the DNS lookup failed</p>
  </blockquote>
  
  <ol start="3">
  <li><code>bar.foo.com/file1</code>  results in GETs of [file]=>/process.php [sub]=>bar</li>
  </ol>
  
  <p>I think it may be due to the way that HG structures my addon domains - as a subdomain.  So now it thinks I'm trying to remap a subdomain of a subdomain...if that makes sense.</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong><br>
  After wildcard subdomains was added and .htaccess modified as below, it looks as though it's working as needed.  </p>
  
  <pre><code>Options +FollowSymlinks  
  RewriteEngine On  
  
  RewriteCond %{REQUEST_FILENAME} !-f  
  RewriteCond %{REQUEST_FILENAME} !-d  
  
  RewriteCond %{HTTP_HOST} !^www  
  RewriteCond %{HTTP_HOST} !^bar\.com$  
  
  RewriteCond %{HTTP_HOST} ^(^.*)\.bar\.com$  
  
  RewriteRule ^(.*)/$  index.php?userId=%1&amp;fileName=$1  
  </code></pre>