RewriteEngine On

# Remove direct access to hidden files
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

# If file or folder exists, serve it directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Send everything else to index.php
RewriteRule ^ index.php [QSA,L]