RewriteEngine On

DirectoryIndex index.html

# Serve real files/directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Redirect .html to clean URL
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC]
RewriteRule ^(.+?)\.html$ /$1 [R=301,L,NE]

# Extensionless to .html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

# Directory index fallback
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)/$ $1/index.html [L]