注意:下面的{baseurl}为相对域名的站点目录。

RewriteEngine On 
RewriteCond %{THE_REQUEST} ^.*/index\.(html|php)
RewriteRule ^(.*)index.(html|php)$ /{baseurl}/$1 [R=301,L]

假设,使https://domain.com/mywebsite/index.html重定向至https://domain.com/mywebsite/,
或者其下层页面https://domain.com/mywebsite/about/index.html重定向至https://domain.com/mywebsite/about/。方法如下:

RewriteEngine On 
RewriteCond %{THE_REQUEST} ^.*/index\.(html|php)
RewriteRule ^(.*)index.(html|php)$ /mywebsite/$1 [R=301,L]