Options -Indexes
RewriteEngine On

# 1. Forward everything to the public directory
RewriteRule ^$ public/index.php [L]

# 2. Map existing files and folders to public/
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -d
RewriteRule ^(.*)$ public/$1 [L]

# 3. Everything else goes to the main router
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [QSA,L]
