什么mod_rewrite规则将301重定向/example.html到/ example?

时间:2010-03-10 09:16:56

标签: .htaccess mod-rewrite

我想翻译或301重定向网址,例如:

www.domain.com/example.html至www.domain.com/example

以下是当前的重写规则:

   RewriteEngine On
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [QSA,L]
   RewriteCond %{SERVER_PORT} 80 

2 个答案:

答案 0 :(得分:1)

尝试RewriteRule (.+)\.html$ $1 [R=301]

答案 1 :(得分:1)

请尝试以下方法:

RewriteRule ^(.+)\.html$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L]