301重定向与htaccess问题

时间:2011-01-27 20:57:10

标签: wordpress .htaccess redirect tumblr

我今天在Tubmlr有一个博客,我的域名是这样的:blog.example.com。我博客中帖子的URL就像这个博客.example.com/post/34545435345/some-title-etc

现在我已将所有内容移至托管的Wordpress,我的域名为www.example.com。 Wordpress中来自Tumblr的帖子现在有了这样的网址:www.exampe.com?p = 34545435345

我想设置一个.htaccess到301从我的旧子域重定向到我的新博客。我在.htaccess -file中尝试了这个规则,但它似乎不起作用:

RewriteEngine On
RewriteRule ^/?posts/([0-9]+).*$ http://www.example.com/$1

2 个答案:

答案 0 :(得分:1)

对于遇到同样问题的所有其他人,这是我的解决方案:

RewriteEngine On
RewriteRule ^/?post/([0-9]+).*$ http://www.example.com/?p=$1 [R=301,L]

答案 1 :(得分:0)

看起来这只是因为你的例子和你的RewriteRule不一致:你的规则有/ posts /而不是/ post,你的目的地缺少“?p =”。您还应该添加R = 301标志。试试这个:

RewriteEngine On
RewriteRule ^/?post/([0-9]+).*$ http://www.example.com/?p=$1 [R=301]