htaccess重写.htm到html无法正常工作

时间:2013-04-22 10:02:54

标签: php html .htaccess mod-rewrite

在我网站的.htaccess文件中,我添加了以下规则,将所有扩展名为.htm的请求重写为.html:

RewriteRule ^(.*)\.htm$ $1.html [NC]

我网站上的大多数网址都被正确重写,但没有重写以下网址。我不知道为什么这个URL没有被重写规则捕获:

http://www.mydomain.com/view/186/4-test-limited.htm

非常感谢任何帮助

1 个答案:

答案 0 :(得分:6)

您需要先激活mod_rewrite。

<强>尝试:

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1.html [R=permanent]

R=permanent标志告诉Apache发出永久重定向301响应,这对搜索引擎友好。

此外,还有在线提供的这些优秀资源:

还值得一试: