使用.htaccess文件将www.mysite.com/index.html重定向到www.mysite.com/ [英] Redirect www.mysite.com/index.html to www.mysite.com/ with .htaccess file

查看:67
本文介绍了使用.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]

这篇关于使用.htaccess文件将www.mysite.com/index.html重定向到www.mysite.com/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆