日期:2014-05-17  浏览次数:20475 次

网址改变,求救RewriteRule 正则表达式
因为之前网址感觉不够规范,所以重新调整了URL,但是没想到,百度提交删除网址好久了,现在收录还是以前网址,为了不影响客户访问,现在想把旧的URL批量重定向到新的URL,
旧格式如下:http://www.songhuala.com/p1099/北京礼品/China_flowers_info.html
新格式如下:http://www.songhuala.com/-p-1099.html

我在.htaccess 中做了如下重定向,

RewriteEngine on
RewriteCond %{REQUEST_URI} ^p/d+\/.*\/China_flowers_info\.html$
RewriteRule ^(.*)$ ^-p-/d+\.html$1 [R=301,L]

但怎么也定向不到正确新URL来,希望朋友们能帮忙指点下,我测试一个下午,还是没改好这个正则表达式。请各位看官不吝赐教。感激不尽。
.htaccess 正则表达式 RewriteRule 批量网址重定向 seo?url?重写

------解决方案--------------------
RewriteCond %{REQUEST_URI} ^p/d+\/.*\/China_flowers_info\.html$
RewriteRule ^(.*)$ ^-p-/d+\.html$1 [R=301,L]

标红部分似乎有误
------解决方案--------------------
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} p(\d+)
RewriteRule p(\d+) http://www.songhuala.com/-p-$1.html [R=permanent,L]