php - htaccess redirect if does not start with folder -


i create white list folder , redirect others requests index

url.com/public/.* <-- can access file on public folder url.com/xxxx <-- redirect index.php 

i use .htaccess (but doesn't work on 1and1 '500 error')

<ifmodule mod_rewrite.c>      <ifmodule mod_negotiation.c>         options -multiviews     </ifmodule>      rewriteengine on      rewriterule !^public/.* index.php [l,nc]      rewritecond %{request_filename} !-f     rewriterule ^ index.php [l]  </ifmodule> 

any idea ?

try :

rewriteengine on rewritecond %{request_uri} !^/index\.php rewriterule !^public /index.php [l]