« SetEnvIf and SetEnvIfNoCase ExamplesFetch Feed Subscribers from Google Reader with CURL »
Jan 07, 08
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..
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
For a non-htaccess solution FeedBurner recommends the following WordPress Plugin FeedBurner Plugin v2.2
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# 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]
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 - http://www.askapache.com/feed/
feedburner feed - http://feeds.feedburner.com/apache/htaccess
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?
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:
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/
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!
« SetEnvIf and SetEnvIfNoCase ExamplesFetch Feed Subscribers from Google Reader with CURL »
Resource Metadata - Trackback - Feed for this Entry
This work by AskApache.com is licensed under the most accommodating license type available, just credit source according to license. .htaccess examples
03.26.08 at 11:50 am
I’ve been looking all over for a possible solution to my problem, but can’t seem to find one yet. Maybe you could help:
I used to use http://blogname/wp-rss2.php?tag=abc to get certain posts with the abc tag. I installed WP feedburner plugin, and am wondering if I could do the same thing (filter by tag).
Any help is greatly appreciated.
01.18.08 at 6:37 pm
i am looking for wordpress “
yourwebsite.com/feed” redirection back to homepage itself. Sorry if this is not relevant.I have to do this because the /feed is appear at search engine, instead of the homepage. Hope to do a permanent redirect 301 back to homepage. Which means disable the /feed page.
I tried editing the .htaccess. Cant get it work.
11.01.07 at 11:35 pm
Your guide to using Feedburner with Wordpress seems to be the best I’ve seen, but I still have some questions:
1) Is it required to have following URL structure:
/%year%/%monthnum%/%day%/%postname%/What if I want to use just
/%postname%/(myblog.com/post-name/)?2) What I have to do if I want to use MyBrand feature? (I already created necessary CNAME DNS records and enabled that feature in Feedburner account settings)