肖老师的博客 黄金价格曲线图网址
Oct 10
作者: 肖建彬 | 可以转载, 转载时务必以超链接形式标明文章原始出处和作者信息及版权声明
网址:http://www.xiaojb.com/archives/it/mod_rewrite-movedomain.shtml

今天给网站做整站迁移,使用了mod_rewrite模块。规则如下
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !xiaojb.com [OR]
RewriteCond %{HTTP_HOST} !www.xiaojb.com
RewriteRule ^(.*)$ http://www.xiaojb.com$1 [R=301,L]
RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3
</IfModule>

R=301 apache返回一个HTTP/1.0 301 Moved Permanently,过段时间看看搜索引擎抓取老域名的效果。
L是最后一条RewriteCond有效的规则。它以后的不受RewriteCond的限制。

Leave a Reply