title: How to route specific URL segments to separate web root directories?
body: <p>My yii project has following structure:  </p>
  
  <pre><code>webapp  
  ----frontend  
  --------www  
  ------------index.php
  ----backend  
  --------www  
  ------------index.php  
  ----api  
  --------www  
  ------------index.php
  </code></pre>
  
  <p><a href="https://github.com/tonydspaniard/yiinitializr-advanced" rel="nofollow">https://github.com/tonydspaniard/yiinitializr-advanced</a>  </p>
  
  <p>Apache 2.2 </p>
  
  <p>Each www directory has own .htaccess file. For example "webapp/frontend/www/.htaccess":     </p>
  
  <pre><code>Options +FollowSymlinks
  
  RewriteEngine on
  
  RewriteBase /
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  RewriteRule ^([^/].*)$ /index.php/$1 [L]
  </code></pre>
  
  <p>For separate parts of application i use subdomains "api.webapp.com","admin.webapp.com" (symlinks in public_html folder):        </p>
  
  <pre><code>webapp.com -&gt; webapp/frontend/www   
  api.webapp.com -&gt; webapp/api/www  
  admin.webapp.com -&gt; webapp/backend/www
  </code></pre>
  
  <p>But i have problems with cross domain ajax requests to api, and i want to get something like this:  </p>
  
  <pre><code>http://webapp.com -&gt; webapp/frontend/www/index.php  
  http://webapp.com/api/ -&gt; webapp/api/www/index.php   
  http://webapp.com/admin/ -&gt; webapp/backend/www/index.php   
  </code></pre>
  
  <p>What is the right way to route URL segment to specific web root directory? Aliases, .htaccess, symlinks, maybe something else?</p>