Redirecting RSS to Feedburner
Pouring over my system and server logs I noticed that my raw WordPress feed was being accessed by some suspicious looking bots and addresses, a few were even scraping entire posts and republishing them illegally. I was a little intrigued because I had installed the Feedburner.com recommended WordPress plugin to redirect feeds to feedburner- FeedSmith and obviously it wasn't doing what it claimed to do.. Namely, redirect ALL requests for feeds to the feedburner url..
WordPress Feed Rewrites
Using the AskApache RewriteRules Viewer plugin for WordPress, we see exactly what URI's are able to access the feed scripts on a WordPress Blog, at least using internal rewrites. Some of these are quite accessible by everyone when using the FeedBurner recommended plugin, FeedSmith.
wp-atom.php$ == index.php?feed=atom wp-rdf.php$ == index.php?feed=rdf wp-rss.php$ == index.php?feed=rss wp-rss2.php$ == index.php?feed=rss2 wp-feed.php$ == index.php?feed=feed (.+?)/(feed|rdf|rss|rss2|atom)/?$ == index.php?category_name=$1&feed=$2 wp-commentsrss2.php$ == index.php?feed=rss2&withcomments=1 feed/(feed|rdf|rss|rss2|atom)/?$ == index.php?&feed=$1 (feed|rdf|rss|rss2|atom)/?$ == index.php?&feed=$1 comments/feed/(feed|rdf|rss|rss2|atom)/?$ == index.php?&feed=$1&withcomments=1 comments/(feed|rdf|rss|rss2|atom)/?$ == index.php?&feed=$1&withcomments=1
htaccess code to redirect feed to feedburner
For a non-htaccess solution FeedBurner recommends the following WordPress Plugin FeedBurner Plugin v2.2
# BEGIN WordPressRewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(feed|wp-atom|wp-feed|wp-rss|wp-rdf|wp-commentsrss)(.+) HTTP/ [NC,OR] RewriteCond %{QUERY_STRING} ^feed [NC] RewriteCond %{HTTP_USER_AGENT} !^(FeedBurner|FeedValidator) [NC] RewriteRule .* http://feeds.askapache.com/apache/htaccess? [R=307,L] RewriteRule ^comments/?.*$ http://feeds.feedburner.com/apache/htaccess/comments [L,R=302]
Using htaccess (preferred)
You need an .htaccess that is created/modified by wordpress via the Permalink/mod-rewrite option. Go to Options>Permalinks in the wordpress administration menu and enable "fancy" urls by adding /%year%/%monthnum%/%day%/%postname%/
at "structure".
blog feed - https://www.askapache.com/feed/ feedburner feed - http://feeds.feedburner.com/apache/htaccess
More info on feedburner forum topic
The following is a short quote from that document
If you've had a feed for any length of time, your readers are using your current feed's URL in their news aggregators How can you painlessly migrate their requests from your old server/feed to your newly burned FeedBurner feed, so all of your syndication traffic takes advantage of our services?
Using Wordpress Plugins
The Ordered List WordPress FeedBurner Plugin or the Flagrant disregard Feedburner Plugin will simplify the process.
Google actually lets you submit your RSS feed as a sitemap in the webmaster tool!
NOTES:
- Both the feedburner plugin and the instructions below will only work if you already have an .htaccess that is created/modified by wordpress via the Permalink/mod-rewrite option.
- If you have index.php in your permalink structure you have to use a hack. This hack only forwards part of the RSS feeds. To forward all of your feeds to feedburner use this hack.
- If you have WordPress installed into a folder other than your root folder, you may encounter errors. If so, try Thatedeguy's Hack for a workaround.
Finding Your Feed URL
There are times when you want to tell someone your site's feed address or URL, or you need it to submit it to search engines and directories, many of which now accept feed URL submissions. There are four possible URLs for each of your feeds. Any of these will work.
http://example.com/wp-rss.php http://example.com/wp-rss2.php http://example.com/wp-rdf.php http://example.com/wp-atom.php
Or you can access them like this:
http://example.com/?feed=rss http://example.com/?feed=rss2 http://example.com/?feed=rdf http://example.com/?feed=atom
If you are using custom permalinks, you should be able to reach them through this usage:
http://example.com/feed/ http://example.com/feed/rss/ http://example.com/feed/rss2/ http://example.com/feed/rdf/ http://example.com/feed/atom/
Alternative .htaccess mod_rewrite fix
I have two feedburner feeds, on for posts and one for comments that I wanted to ensure ALL feed requests of any type would work with - your rewrite list of URLs was very helpful in figuring this out. So I came up with this:
Thanks to Mike Baptiste for contributing this excellent alternative!
# Redirect global post and comment feeds to Feedburner without loading WP RewriteCond %{REQUEST_URI} ^/(feed|wp-atom|wp-feed|wp-rss|wp-rdf).* [NC,OR] RewriteCond %{QUERY_STRING} .*feed=.* [NC] # Ditch if they want a comment feed or a feed limited to posts with comments RewriteCond %{QUERY_STRING} !.*withcomments=.* [NC] # Any specification of a post ID we skip since it's post specific RewriteCond %{QUERY_STRING} !.*p=.* [NC] RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator|Recent) [NC] RewriteRule .* http://feeds.feedburner.com/PostFeed? [L,R=307] # Comment feeds can be called via /comments, wp-commentsrss2, or withcomments=1 to the main feed script RewriteCond %{REQUEST_URI} ^/(comments/|wp-commentsrss2).* [NC,OR] RewriteCond %{QUERY_STRING} ^.*withcomments=.*$ [NC] # Calls directly to the feed scripts that include 'withcomments' limit to POSTS with comments RewriteCond %{REQUEST_URI} !^/(wp-atom|wp-feed|wp-rss|wp-rdf).* [NC] # Any specification of a post ID we skip since it's post specific RewriteCond %{QUERY_STRING} !.*p=.* [NC] RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator|Recent) [NC] RewriteRule .* http://feeds.feedburner.com/CommentFeed? [L,R=307]
I noticed that when I switched over to Feedburner I stopped having all the individual post and comments feeds.... That is now fixed by only switching to Feedburners feed for /feed/* or /comments/* I had this same issue when I migrated my wordpress feeds to feedburner using 302 redirects in mod_rewrite based on the USER_AGENT. The result was I lost all my other comment and individual post feeds.. But I just realized that all I had to do was change the htaccess code to only apply feedburner when the REQUEST_URI is either /feed/ or /comments/ Now it all works perfectly!
« Apache Environment Variables CGI ScriptFetch Feed Subscribers from Google Reader with CURL »
Comments