让网站支持原来的blog url风格

| | Comments (0) | TrackBacks (0)

    原来网站是我用rails程序写的,发表的文章URL都是类似这样的http://yigebuliu.com/article/show/aritcle_id
    现在我改用movable type,虽说原来写的文章数据都保留了,但用这种URL访问过来,由于无法解析URL,全部报404错误页面,如google,baidu等搜索引擎还保留着原来那种URL,另外一些网站引用到网站的链接也是用的原来的URL,可movable 没有支持这种风格(反正我不知道怎么设).

    因此我想解决这个问题,最后用了rewrite rule来解决此问题.记录一下!
首先先编写一个.htaccess文件,内容如下
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/article/show/.*$
RewriteRule ^(.*)$ $1.html
然后在网站目录上建立一个article/show目录
最后把movable type发布出来的静态html copy 到此目录下.

哈哈,结果用浏览器访问原来的url,比如:http://yigebuliu.com/article/show/100,再也不是可恶的404了,吼吼,成功,睡觉去也.

 

UPDATE:
看了访问日志,还有http://yigebuliu.com/article/tag/key这种情况.这是原来blog的tag访问方式,好办,再写个rewrite rule就行.

RewriteCond %{REQUEST_URI} ^/article/tag/.*$
RewriteRule ^article/tag/(.*)$ /cgi-bin/mt/mt-search.cgi?search=$1&IncludeBlogs=1

把所有/article/tag/*的这种访问uri全部rewrite成movable type搜索的uri就行了,也就是/cgi-bin/mt/mt-search.cgi?search=key&IncludeBlogs=1

0 TrackBacks

Listed below are links to blogs that reference this entry: 让网站支持原来的blog url风格.

TrackBack URL for this entry: http://www.yigebuliu.com/cgi-bin/mt/mt-tb.cgi/3

Leave a comment

About this Entry

This page contains a single entry by UPDATE published on February 3, 2008 12:53 AM.

微软收购Yahoo能给我们带来什么 was the previous entry in this blog.

米奇奇妙年,全家更开心! is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01a