使用htaccess重定向删除index.html

时间:2016-01-15 10:20:59

标签: .htaccess redirect

我们网站上有重复的网页,我们需要将任何以index.html结尾的内容重定向到非index.html;

/van-insurance/pick-up-insurance.html 301重定向到 / VAN-保险/拾取保险

/van-insurance/private.html 301重定向到 / VAN-保险/私有

这个htaccess代码是什么?

2 个答案:

答案 0 :(得分:0)

这应该足够了:

RewriteEngine On

RewriteRule ^(.+)\.html$ http://www.domain.com/$1 [L,R=301]

答案 1 :(得分:0)

这应该可以解决问题:

RedirectMatch 301 ^(.*)\.html $1

文档:http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch