 RewriteEngine on

 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_URI} (.+)/$
 RewriteRule ^ %1 [L,R=301]

 RewriteCond %{REQUEST_URI} !^public

 RewriteRule ^(.*)$ public/$1 [L]
