RewriteEngine On

# 重定向多余路径
RewriteCond %{REQUEST_URI} ^/www/wwwroot/www\.btcmvc\.com/(.*)$ [NC]
RewriteRule ^www/wwwroot/www\.btcmvc\.com/(.*)$ /$1 [L,R=301]

# 确保目录以斜杠结尾
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

# 隐藏 index.html
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^(.*?)index\.html$ /$1 [L,R=301,NC,NE]

# 隐藏所有 .html 扩展名
RewriteCond %{THE_REQUEST} \s/+(.*?)\.html[\s?] [NC]
RewriteRule ^ %1 [R=301,L,NE]

# 内部重写：为无扩展名的请求添加 .html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L]