由于thinkphp的url不带.html后缀也能访问,于是通过apache rewrite规则重写了301重定向,
类似于domain.com/news/3之类的url全部跳转到domain.com/news/3.html
.htaccess文件如下
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.html)$ [NC]
RewriteRule ^/?(.*)$ /$1.html [QSA,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>