新网DNS服务中断数小时,众网站抓瞎(包括我) 推荐一款注册表实时保护软件:RegDefend
Sep 22
作者: 肖建彬 | 可以转载, 转载时务必以超链接形式标明文章原始出处和作者信息及版权声明
网址:http://www.xiaojb.com/archives/it/mt2wp-rss-uri.shtml

这个其实是解决MovableType时代变更分类目录名称和迁移后RSS的URI变化的问题。
目录变更主要是cat-17变更为leisure,使得众多的文章无法访问。
RSS由原来的index.rdf/index.xml变更为/feed/。

主要是修改了模版中404.php。顶部加入了如下的代码

  1. <?php
  2. $new = preg_replace(
  3.                 array(
  4.                         '/^\/index.rdf/',
  5.                         '/^\/index.xml/',
  6.                         '/\/cat-16\//',
  7.                         '/\/cat16\//',
  8.                         '/\/cat-17\//',
  9.                         '/\/cat17\//',
  10.                         '/\/cat-20\//',
  11.                         '/\/cat20\//'
  12.                         ),
  13.                 array('/feed/',
  14.                         '/feed/',
  15.                         '/personal/',
  16.                         '/personal/',
  17.                         '/leisure/',
  18.                         '/leisure/',
  19.                         '/life/',
  20.                         '/life/'
  21.                         ),
  22.                 $_SERVER['REQUEST_URI']
  23.                 );
  24.  
  25.  
  26. if($new != $_SERVER['REQUEST_URI']) {
  27.   header("HTTP/1.0 301 Moved Permanently");
  28.   header("Location: http://www.xiaojb.com{$new}");
  29.   exit();
  30. }
  31. ?>

Leave a Reply