title: htaccess rewrite rule exclude directory from wildcard
body: <p>I have a htaccess with RewriteRule that if you access my domain it will direct to public folder. <em>See my code below</em></p>
  
  <pre><code>RewriteEngine on
  RewriteRule ^(.*) public/$1 [L]
  </code></pre>
  
  <p>Now I want to exclude demo directory (www.mydomain.com/demo) from the wildcard.
  I try to use this code but didn't work</p>
  
  <pre><code>RewriteRule ^demo($|/) - [L]
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>RewriteRule /demo/$1 -f
  </code></pre>
  
  <p>Full htaccess code</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{REQUEST_URI} !^/demo
  RewriteRule ^(.*) public/$1 [L]
  
  # Deflate Compression by FileType
  &lt;IfModule mod_deflate.c&gt;
   AddOutputFilterByType DEFLATE text/plain
   AddOutputFilterByType DEFLATE text/html
   AddOutputFilterByType DEFLATE text/xml
   AddOutputFilterByType DEFLATE text/css
   AddOutputFilterByType DEFLATE text/javascript
   AddOutputFilterByType DEFLATE application/xml
   AddOutputFilterByType DEFLATE application/xhtml+xml
   AddOutputFilterByType DEFLATE application/rss+xml
   AddOutputFilterByType DEFLATE application/atom_xml
   AddOutputFilterByType DEFLATE application/javascript
   AddOutputFilterByType DEFLATE application/x-javascript
   AddOutputFilterByType DEFLATE application/x-shockwave-flash
  &lt;/IfModule&gt;
  
  # Set browser caching to 1 month
  &lt;IfModule mod_expires.c&gt;
   ExpiresActive On
   ExpiresByType text/css "access plus 1 month"
   ExpiresByType text/javascript "access plus 1 month"
   ExpiresByType text/html "access plus 1 month"
   ExpiresByType application/javascript "access plus 1 month"
   ExpiresByType image/gif "access plus 1 month"
   ExpiresByType image/jpeg "access plus 1 month"
   ExpiresByType image/png "access plus 1 month"
   ExpiresByType image/x-icon "access plus 1 month"
  &lt;/IfModule&gt;
  
  &lt;ifmodule mod_headers.c&gt;
   &lt;filesmatch "\\.(ico|jpe?g|png|gif|swf)$"&gt;
    Header set Cache-Control "max-age=2592000, public"
   &lt;/filesmatch&gt;
   &lt;filesmatch "\\.(css)$"&gt;
    Header set Cache-Control "max-age=604800, public"
   &lt;/filesmatch&gt;
   &lt;filesmatch "\\.(js)$"&gt;
    Header set Cache-Control "max-age=216000, private"
   &lt;/filesmatch&gt;
  &lt;/ifmodule&gt;
  </code></pre>
  
  <p>Hope someone helps me. </p>
  
  <p>Thanks</p>