title: .htaccess rewriterule syntax
body: <p>I need to make some rewrite rules for inclusion in .htaccess with the following conditions:</p>
  
  <pre><code>(www).site.com/setup   --&gt; redirects to: www.site.com/setup
  demo.site.com/setup    --&gt; redirects to: www.site.com/demo/setup
  (www).site.com/xyz   --&gt; redirects to: www.site.com/web/xyz
  demo.site.com/xyz    --&gt; redirects to: www.site.com/demo/web/xyz
  </code></pre>
  
  <p>Note that (www) means the user can both input and not input www and "xyz" can be any string but different than the keyword "setup" (due to the first two rules).</p>
  
  <p>This is what I tried (using [L] to make exceptions) but I'm not sure if it is ok enough:</p>
  
  <pre><code>RewriteCond ${REQUEST_URI} demo.
  RewriteCond ${REQUEST_URI} /setup
  RewriteRule /demo/setup [L]
  
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteCond ${REQUEST_URI} /setup
  RewriteRule /setup [L]
  
  RewriteCond ${REQUEST_URI} demo.
  RewriteRule ^/(.*)$ www.site.com/demo/web/$1 [L]
  
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule ^/(.*)$ www.site.com/web/$1 [L]
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Luciano</p>