title: Rewrite directory to subdomain
body: <p>I have a page with two subdomains: <a href="http://cw.sidenote.hu" rel="nofollow">cw.sidenote.hu</a> and <a href="http://cellwars.sidenote.hu" rel="nofollow">cellwars.sidenote.hu</a>, both point to <a href="http://sidenote.hu/cellwars/" rel="nofollow">sidenote.hu/cellwars/</a>.</p>
  
  <p>What I'd like to achieve that when I visit <code>cw.sidenote.hu</code> or <code>cellwars.sidenote.hu</code> that the URL change to/stay in <code>cellwars.sidenote.hu</code> format, and don't change to <code>sidenote.hu/cellwars/</code>.</p>
  
  <p>This is what I currently have in my <code>.htaccess</code> file:</p>
  
  <pre><code>RewriteEngine on
  
  # Some hosts require a rewritebase rule, if so, uncomment the RewriteBase line below. If you are running from a subdirectory, your rewritebase should match the name of the path to where stacey is stored.
  # ie. if in a folder named 'stacey', RewriteBase /stacey
  #RewriteBase /cellwars
  
  ErrorDocument 404 /404.html
  
  # Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !public/
  RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
  RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]
  
  # Add a trailing slash to directories
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !(\.)
  RewriteCond %{REQUEST_URI} !(.*)/$
  RewriteRule ([^/]+)$ $1/ [L]
  
  # Rewrite any calls to /* or /app to the index.php file
  RewriteCond %{REQUEST_URI} /app/$
  RewriteRule ^app/ index.php [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ index.php?$1 [L]
  
  # Rewrite any file calls to the public directory
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !public/
  RewriteRule ^(.+)$ public/$1 [L]
  </code></pre>
  
  <p>These are the rewrite rules I'v tried to use, but it seems this gets the site into an infinite rewrite loop:</p>
  
  <pre><code># cw.sidenote.hu -&gt; cellwars.sidenote.hu
  RewriteCond %{HTTP_HOST} ^cw.sidenote.hu$
  RewriteRule ^(.*)$ http://cellwars.sidenote.hu/ [R=301,L]
  
  # sidenote.hu/cellwars/* -&gt; cellwars.sidenote.hu/*
  RewriteCond %{REQUEST_URI} ^/cellwars/?(.*)$
  RewriteRule ^(.*)$ http://cellwars.sidenote.hu/%1 [R=301,L]
  </code></pre>
  
  <p>This is what I got back from Chrome:</p>
  
  <pre><code>This webpage has a redirect loop
  The webpage at http://cellwars.sidenote.hu/ has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
  Here are some suggestions:
      Reload this webpage later.
      Learn more about this problem.
  Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
  </code></pre>
  
  <p>Could anyone help me? Thanks in advance!</p>