title: htaccess and rewriting my URLs
body: <p>I'm trying to organise my websites with .htaccess, and I want to following configuration:</p>
  
  <ul>
  <li>The URL of the main site has to be beta.example.com/portal/</li>
  <li>The other sites should be in beta.example.com/othersite/</li>
  <li>If users go to beta.example.com, they should be redirected 301 to
  beta.example.com/portal/</li>
  <li>beta.example.com/portal (without the trailing slash) should redirect to beta.example.com/portal/</li>
  <li>/portal/ is not a physical file path on the server. I want all these sites to
  be in a folder together, say /html/www/websites/</li>
  <li>The folder the portal resides in, should not be located in
  /html/www/websites/portal/, but I want to be able to switch the live
  site to a new version (in a different folder) on the server, quickly,
  invisible, without any downtime. This goes for all sites by the way.</li>
  </ul>
  
  <p>I'm currently working with two or three .htaccess files: one in the root (www.), which directs beta.example.com to the folder /websites/</p>
  
  <pre><code>#RewriteBase / #should I use rewritebase or not?
  /RewriteCond    %{HTTP_HOST}        ^beta.example.com$
  RewriteRule (.*)            websites/$1 [L,NC]
  </code></pre>
  
  <p>A .htaccess file is in the folder /websites/, and maybe another one or maybe not in the folder a site resides in.</p>
  
  <pre><code>RewriteBase             /websites    # or, not...
  # rewrite the active site to the folder /portal_v1.0/
  RewriteCond     %{REQUEST_URI}      ^/portal/
  RewriteRule     (.*)            portal_v1.0/$1 [L]
  # rewrite the root to /portal/
  RewriteRule     ^$      http://beta.example.com/portal/         [L,NC]
  </code></pre>
  
  <p>However, I still can't get this to work exactly the way I want. One problem is what beta.example.com/portal redirects to www.example.com/websites/portal/ , I don't want that. Help! Thanks in advance!</p>