【发布时间】:2011-06-06 21:58:48
【问题描述】:
以下是场景,我有一个网站,它曾经是一个静态 HTML 网站和一个使用子域 (http://blog.domain.com) 的 WordPress 博客。
我最近将所有内容合并到一个 WordPress 安装中。为了维护旧链接,我不得不将“http://blog.domain.com/index.php/2010/10/16/post-name”之类的请求重写为“http://domain.com/index.php/2010” /10/16/post-name”。我的问题是,当我试图访问“http://blog.domain.com”时,当我希望它转到“http://domain.com/”时,我会被重定向到“http://domain.com” index.php/blog”。
所以,如果用户请求“http://blog.domain.com”(本身,带或不带斜杠),我希望它转到“http://domain.com/index.php/blog ”。如果他们请求“http://blog.domain.com/some-link-to-a-post”的旧 URL,我希望它重定向到“http://domain.com/some-link-to-一个帖子”。换句话说,如果它是实际帖子的 URL,我只想去掉“博客”子域。如果它是指向博客主页面的旧链接,我想删除“博客”子域并附加“/index.php/blog”
http://blog.domain.com/ -> http://domain.com/index.php/blog
http://blog.domain.com/index.php/2010/10/16/post-title -> http://domain.com/index.php/ 2010/10/16/post-title
希望这很清楚。我不是 htaccess 专家,所以希望有人可以在这里帮助我。提前致谢!
【问题讨论】:
标签: .htaccess mod-rewrite blogs subdomain