title: .htaccess optimization
body: <p>Can anyone help with .htaccess optimization?
  Actually I have next code:</p>
  
  <pre><code>RewriteEngine on
  RewriteBase /
  DirectoryIndex frontend/www/index.php
  
  RewriteCond %{REQUEST_FILENAME} !-f
  
  RewriteCond %{REQUEST_URI} cpanel/(.*)$
  # Why not "-f" - because it's domain of 3d level: VirtualDocumentRoot /path/to/htdocs/%-3/ and if I use "-f" file not founds :(
  RewriteCond backend/www/%1 -F
  RewriteRule . backend/www/%1 [L]
  
  RewriteCond %{REQUEST_URI} cpanel/(.*)$
  RewriteCond backend/www/%1 !-F
  RewriteRule . backend/www/index.php?b=%1 [L]
  
  RewriteCond %{REQUEST_URI} !cpanel/(.*)$
  RewriteCond frontend/www%{REQUEST_URI} -F
  RewriteRule . frontend/www%{REQUEST_URI}
  
  RewriteCond %{REQUEST_URI} !cpanel/(.*)$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule . frontend/www/index.php?f=%{REQUEST_URI}
  </code></pre>
  
  <p>Folders structure:</p>
  
  <pre><code>.
  ├── .htaccess (with code I provided)
  ├── frontend
  │   ├── www
  │       ├── css
  │       │   ├── base.css
  │       └── index.php
  ├── backend
      ├── www
          ├── css
          │   ├── base.css
          └── index.php
  </code></pre>
  
  <p>I need:</p>
  
  <ul>
  <li><strong>my.domain.com/base.css</strong> shows file if it exists in root directory or
  under frontend/www</li>
  <li><strong>my.domain.com/dir/base.css</strong> shows file if it exists in
  root/dir directory or under frontend/www/dir</li>
  <li><strong>my.domain.com/cpanel/base.css</strong> shows file if it exists in backend/www
  directory</li>
  <li><strong>my.domain.com/cpanel/dir/base.css</strong> shows file if it exists in
  backend/www/dir directory</li>
  <li>if file not found in any of nedded directories I show index.php from frontend/www/index.php or from backend/www/index.php (if URI starts as cpanel/...).</li>
  </ul>
  
  <p>Looks like my .htaccess work good, but I'm not sure of it quality. </p>