简洁的想法

仁爱、喜乐、和平、忍耐、恩慈、良善、信实、温柔、节制

Wordpress to Octopress Rewrite Rules

| Comments

  1. 首先编辑Gemfile, 添加gem ‘rack-rewrite’
1
2
3
4
5
6
7
8
9
10
$ vi Gemfile
source "http://rubygems.org"

group :development do
  gem 'rake'
  ...
end

gem 'sinatra', '1.2.6'
gem 'rack-rewrite'
  1. 在config.ru里面添加rewrite规则
1
2
3
4
5
6
7
8
$ vi config.ru
...
require 'rack-rewrite'

use Rack::Rewrite do
  r301 %r{/\?p=(.*)},  "http://blog.neten.de/posts/$1/"
end
...
  1. 别忘记了更新网站
1
2
3
4
5
$ bundle install
$ rake generate
$ git add .
$ git commit -am "add rewrite"
$ git push heroku master

访问一下Google中网站的旧链接吧, 是不是转到新站上来了呢?

Comments