使用.htaccess文件将www.mysite.com/index.html重定向到www.mysite.com/

问题描述:

我希望重定向www.mysite.com/index.html

I wish to redirect www.mysite.com/index.html

www.mysite .com /

www.mysite.com/

,但我不希望使用index.html重定向所有地址,例如

but I do not wish to redirect all addresses with index.html like

www.mysite .com / folder / index.html

www.mysite.com/folder/index.html

www.mysite.com/folder /

www.mysite.com/folder/

因此,仅将第一个index.html页面重定向到网站的根目录。

So, just to redirect first index.html page to root of site.

将以下内容添加到www.mysite.com的根文件夹中的.htaccess文件中

Add the following to the .htaccess file in the root folder of www.mysite.com

RewriteEngine On
RewriteBase /

# redirect html pages to the root domain
RewriteRule ^index\.html$ / [NC,R,L]