2012-10-18 50 views
1

我最近已将静态网站升级到CMS,并且我想将旧网站的所有html文件重定向到网站的根目录(http:// www。 url.com),而不会影响CMS的PHP。htaccess:仅将.html文件重定向到网站根目录

当前htaccess的是这样的

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME}/index.html !-f 
RewriteCond %{REQUEST_FILENAME}/index.php !-f 
RewriteRule . index.php [L] 
</IfModule> 

显然任何新的规则我补充不得与此相冲突。

我想老文件(url.com/page.html)重定向到url.com。

我在搜索后尝试了一些东西,但没有任何工作。任何帮助赞赏。

回答

1

您需要添加这些规则,你的CMS规则以前

RewriteEngine On 

# check that the request isn't for a legitimate existing resource 
RewriteCond %{REQUEST_FILENAME} !-f 

# redirect the .html request to the site root 
RewriteRule ^(.*)\.html$/[L,R=301] 
相关问题