.htaccess 重定向_如何使用.htaccess将WordPress Feed重定向到Feedburner

.htaccess 重定向

.htaccess is a powerful tool. Let’s look at how to using .htaccess to redirect WordPress feeds to feedburner.

.htaccess是一个功能强大的工具。 让我们看看如何使用.htaccess WordPress提要重定向到feedburner。

Let’s use my blog as the example. The WordPress’s feed url of my blog is https://www.systutorials.com/feed/. Now I want to redirect it to feedburner with url http://feeds.systutorials.com/systutorials .

让我们以我的博客为例。 我的博客的WordPress提要URL为https://www.systutorials.com/feed/ 。 现在,我想使用url http://feeds.systutorials.com/systutorials将其重定向到feedburner。

The idea is quite straightforward: For every request to https://www.systutorials.com/feed/, first check whether the HTTP_USER_AGENT is FeedBurner or FeedValidator. If HTTP_USER_AGENT is one of these two feed burners, do nothing and so feeds from WordPress will be returned to the feed burner. Otherwise, redirect the request to http://feeds.systutorials.com/systutorials since it is from a normal user’s browser or feed reader. Through this method, the normal user can read the feeds from feedburner, while feedburner can get the original feeds from WordPress. We can also enjoy the other advantages of feedburner, such as tracking and statistical services.

这个想法非常简单:对于对https://www.systutorials.com/feed/的每个请求, 首先检查HTTP_USER_AGENT是FeedBurner还是FeedValidator。 如果HTTP_USER_AGENT是这两个提要燃烧器之一,则什么也不做,因此来自WordPress的提要将返回到提要燃烧器。 否则,将请求重定向到http://feeds.systutorials.com/systutorials,因为它来自普通用户的浏览器或feed 阅读器 。 通过这种方法,普通用户可以从feedburner读取提要,而feedburner可以从WordPress获取原始提要。 我们还可以享受Feedburner的其他优势,例如跟踪和统计服务。

The method
Add these codes to the beginning of the .htaccess file in the root directory of the site:

方法
将这些代码添加到网站的根目录中的.htaccess文件的开头:

# Redirect WordPress feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI}      ^/?(feed.*|comments.*)        [NC]
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner)             [NC]
 RewriteRule ^feed/?.*$          http://feeds.systutorials.com/systutorials        [L,NC,R=302]
</IfModule>

Here the comments feed and posts feed are written together for convenience. Only the feedburner url need to be changed for other WordPress sites.

为了方便起见,这里将评论提要和帖子提要一起编写。 对于其他WordPress网站,仅需要更改feedburner网址。

翻译自: https://www.systutorials.com/how-to-redirect-wordpress-feed-to-feedburner-using-htaccess/

.htaccess 重定向

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值