0

我在域上安装了 Wordpress example.com。我想加载相同的页面(RSS2 提要)example.com/feed.xmlexample.com/feed/我的永久链接是为漂亮的 URL 配置的(带有 pattern %postname%)。

example.com/feed/有效,所以我开始为feed.xml. 在functions.php,我把这个:

function add_feed_xml_route() {
  add_rewrite_rule('feed.xml', 'index.php?feed=rss2', 'top');
}

add_action('init', 'add_feed_xml_route');

我刷新了路线,但是当我转到 时,它会在显示提要之前example.com/feed.xml重定向到。/feed.xml/feed/为什么会重定向?我该如何阻止它?

谢谢!

4

1 回答 1

0

我将通过您的 .htaccess 文件执行此操作,而不是通过 functions.php 执行此操作。它看起来像这样:

redirect 301 /feed.xml http://example.com/feed/

如果您想要有关重定向的基本教程,请查看http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm

我希望这会有所帮助。

于 2012-11-09T23:23:52.220 回答