apache利用.htaccess实现部分页面301
由于网站改版,对访问url进行了改进
原:http://www.tutufu.com/w_weifenlei/DeHaiZi_38251/
现:http://www.tutufu.com/unclassified/DeHaiZi/
栏目w_weifenlei地址改为unclassified,同时,将_38251去除,这个数字是一个内容页ID
RewriteRule ^w_weifenlei/([a-zA-Z]+)_\d+[/]?$ /unclassified/$1/ [L,R=301]
原:http://www.tutufu.com/aiqing/xiaoshidai2qingmushidai_23101/
现:http://www.tutufu.com/aiqing/xiaoshidai2qingmushidai/
将所有内容页的_23101去除
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)_\d+[/]?$ /$1/$2/ [L,R=301]
整个.htaccess代码如下
RewriteEngine On RewriteCond %{HTTP_HOST} ^tutufu.com$ [NC] RewriteRule ^(.*)$ http://www.tutufu.com/$1 [L,R=301] RewriteRule ^w_weifenlei/([a-zA-Z]+)_\d+[/]?$ /unclassified/$1/ [L,R=301] RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)_\d+[/]?$ /$1/$2/ [L,R=301]