因为之前网址感觉不够规范,所以重新调整了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 重写

解决方案 »

  1.   

    RewriteCond %{REQUEST_URI} ^p/d+\/.*\/China_flowers_info\.html$
    RewriteRule ^(.*)$ ^-p-/d+\.html$1 [R=301,L]标红部分似乎有误
      

  2.   

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} p(\d+)
    RewriteRule p(\d+) http://www.songhuala.com/-p-$1.html [R=permanent,L]
      

  3.   

    昨天很着急,一直没答复,今天看到大家回复真是非常感谢。后面通过问朋友介绍,问到idreamsoft.com 枯木,解决了,
    下面是可以完成完成重定向的。RewriteEngine on  
    RewriteRule ^(.*)?p(\d+).*?\.html$   -p-$2\.html [R=301,L]