Fix WordPress RSS feeds

By default wordpress shows these RSS feed links:

http://www.bhatt.id.au/blog/feed/rss2/

http://www.bhatt.id.au/blog/feed/rss/

http://www.bhatt.id.au/blog/feed/atom/

etc

However, Google looks for RSS feeds named:

  • rss.xml – for an RSS 0.92 or 2.0 feed
  • index.rdf – for an RSS 1.0 feed
  • atom.xml – for an Atom RSS news feed

This means that each day when the GoogleBot visits my Blog, it generates many 404 file not found errors in my website logs by asking over and over again for :

  • http://www.bhatt.id.au/blog/rss.xml
  • http://www.bhatt.id.au/blog/index.rdf
  • http://www.bhatt.id.au/blog/atom.xml

After 15 such errors in the last hour I decided to see what I could do to fix this so that WordPress would display links to my RSS feeds which would stop GoogleBot hassling me with errors….

——-

  1. FTP into your Blogs root directory and rename:
    wp-rss.php -> rss.xml
    wp-rdf.php -> index.rdf
    wp-rss2.php -> rss2.xml
    wp-atom.php -> atom.xml
  2. Open the .htaccess file in your blogs root directory, in my case http://www.bhatt.id.au/blog/.htaccess
  3. Add these lines to .htaccess file, (dont leave any blank lines):

    <files rss.xml>
    ForceType application/x-httpd-php
    </files>
    <files rss2.xml>
    ForceType application/x-httpd-php
    < /files >
    <files index.rdf>
    ForceType application/x-httpd-php
    </files>
    <files atom.xml>
    ForceType application/x-httpd-php
    </files>

    This will force your Apache web server to process the RSS feed files as .PHP, allowing them to generate a feed of your latest Blog posts from the MySQL database even though their file extension is no longer .PHP

  4. Open wp-feed.php from your blogs root directory, and replace:

    case ‘atom’:
    require(‘wp-atom.php’);
    break;
    case ‘rdf’:
    require(‘wp-rdf.php’);
    break;
    case ‘rss’:
    require(‘wp-rss.php’);
    break;
    case ‘rss2′:
    require(‘wp-rss2.php’);
    break;

    With this (below):

    case ‘atom’:
    require(‘atom.xml’);
    break;
    case ‘rdf’:
    require(‘index.rdf’);
    break;
    case ‘rss’:
    require(‘rss.xml’);
    break;
    case ‘rss2′:
    require(‘rss2.xml’);
    break;

  5. Open template-functions-general.php, and replace this:

    $feed_url = get_settings(‘home’) . ‘/feed’;

    With:

    $feed_url = get_settings(‘home’) ;

    Also replace:

    case ‘rdf_url’:
    $output = get_settings(‘siteurl’) .’/wp-rdf.php’;
    if ($do_perma) {
    $output = $feed_url . ‘/rdf/’;
    }
    break;
    case ‘rss_url’:
    $output = get_settings(‘siteurl’) .’/wp-rss.php’;
    if ($do_perma) {
    $output = $feed_url . ‘/rss/’;
    }
    break;
    case ‘rss2_url’:
    $output = get_settings(‘siteurl’) .’/wp-rss2.php’;
    if ($do_perma) {
    $output = $feed_url . ‘/rss2/’;
    }
    break;
    case ‘atom_url’:
    $output = get_settings(‘siteurl’) .’/wp-atom.php’;
    if ($do_perma) {
    $output = $feed_url . ‘/atom/’;
    }
    break;

    With this:

    case ‘rdf_url’:
    $output = get_settings(‘siteurl’) .’/index.rdf’;
    if ($do_perma) {
    $output = $feed_url . ‘/index.rdf’;
    }
    break;
    case ‘rss_url’:
    $output = get_settings(‘siteurl’) .’/rss.xml’;
    if ($do_perma) {
    $output = $feed_url . ‘/rss.xml’; //bhatt.id.au changes to extension to stop google annoying me with 404′s
    }
    break;
    case ‘rss2_url’:
    $output = get_settings(‘siteurl’) .’/rss2.xml’;
    if ($do_perma) {
    $output = $feed_url . ‘/rss2.xml’;
    }
    break;
    case ‘atom_url’:
    $output = get_settings(‘siteurl’) .’/atom.xmlp’;
    if ($do_perma) {
    $output = $feed_url . ‘/atom.xml’;
    }
    break;

  6. Upload the updated .htaccess, wp-feed.php and template-functions-general.php files

Within a few more visits to your website, Googlebot will find and index rss.xml, index.rdf, andatom.xml, and stop generating those annoying 404 File Not Found errors.

DISCLAIMER: These instructions worked on my web server, with my .htaccess file settings, your milage may vary because your server may not support .htaccess files, have a different setup to mine or some other reason.


10 comments on “Fix WordPress RSS feeds

  1. Pingback: GeekMob » GoogleBot & Wordpress RSS feeds

  2. Pingback: A pathetic weblog » Browsing the log files

  3. karsh on said:

    You’re a genius; I was just looking for something like this because I was getting slammed with these requests from Googlebot and Yahoo! Slurp. Excellent! Thanks!

  4. Frank Michlick on said:

    I took a slightly different approach by adding two additional rewrite rules. For more details check my article.

  5. puterfixer on said:

    Hello,

    I have just installed WordPress on my site and followed your tutorial on renaming the RSS feeds (http://www.bhatt.id.au/blog/2004/07/26/fix-wordpress-rss-feeds/).

    Unfortunately, I have ran into problems, even that I checked and double-checked everything I have done. The .htaccess file works correctly, so it doesn’t seem to be the problem. I am getting 500 errors and the hosting’s log says:

    Premature end of script headers: /home/websurf/public_html/blog/index.rdf

    and similar for the other files. The path is correct. They have been set executable too and just renamed, not edited. What am I doing wrong? Thanks in advance.

    Titel/puterfixer

  6. puterfixer on said:

    Regarding the previous inquiry, I’ve got it to work. The problem is that my webhost is running PHP in safe mode as CGI with PHPsuexec (as far as I could understand) instead of running it as an Apache module. That’s why .htaccess directives were being ignored, thus generating the nasty 500 errors. The fix was to create a php.ini file in the root folder of my blog with the instruction “safe_mode = off” in it, and second to use SetHandler directive instead of ForceType in the .htaccess. Perhaps it would be a good idea to add these instructions to your blog. Thanks again!

  7. SpAwN on said:

    Thanks alot, going to try this out now :D

  8. Jonathan Covington on said:

    any idea how to get magpie rss working on a server that PHP can’t open outgoing sockets on. :-)

    Thanks
    J.C

  9. rodrigo on said:

    the “$feed_url = get_settings(’home’) . ‘/feed’;” no exist in my template-functions-general.php

    EDITOR: it is quite likely that the current version of WordPress (1.5.2 “Strayhorn”) has had many changes to its code since I made this blog post which was targetted at users of WordPress 1.2

    Therefore users of newer versions will have to try and find new hacks

  10. ashley on said:

    I have tried it (phew, quite abit of work) and so far without any problem.

    But was wondering, can’t afew RewriteRule do the job?

    EDITOR Please see my last comment above in bold. The instructions are over 2 years old and probaly have lots of mistakes. Also WordPress is now version 2.0.4 not 1.2 so im closing comments