我已经将以前存储在http://www.example.com/ourblog/
的博客移动到域的根目录(http://www.example.com/
)。一切都很完美,但我需要所有以前的谷歌列表来指向新内容。
因此,例如:http://www.example.com/ourblog/category/comedy/
应重定向到http://www.example.com/category/comedy/
并且:http://www.example.com/ourblog/my-post/
应重定向到http://www.example.com/my-post/
等等。
这是一个Wordpress博客,但我在Wordpress文档中找不到任何提供解决方案的东西。
我试着给.htaccess:添加一个简单的规则
RedirectMatch 301 ^/blog/$ http://www.example.com/
和
RedirectMatch 301 ^/blog/.*$ http://www.example.com/
但是,当它将http://www.example.com/blog/
重定向到http://www.example.com/
时,它不处理任何子目录。
我做错了什么?
我会使用更强大的mod_rewrite。这应该会得到您所需要的,并处理任何子目录。
RewriteEngine On
RewriteRule ^ourblog/(.*)/?$ http://www.example.com/$1 [R=301,L]
如果您想使用RedirectMatch指令重定向,
试试这个
RedirectMatch 301 ^/Ourblog/(.*)/?$ http://www.example.com/$1