Fix broken WordPress RSS in GoDaddy Free Hosting Accounts

GoDaddy offers free ad-supported web hosting for any domain you register through them. The hosting is the same as their pay Linux Shared Hosting plans, except that they inject a banner advertisement into the top of every page.

I was able to manually install WordPress onto one of my sites that uses this free hosting, however I found that the WordPress RSS feed was broken. When you go to the default address for a WordPress RSS feed (http://www.domain.com/feed), the page is addressed by a web browser with a mime type of ‘text/html’, even though it is actually an XML document. This results in the GoDaddy ad banner being injected into the XML document, thus invalidating the XML and breaking the RSS feed. Validators will give error messages like:

XML parsing error: :3:0: xml declaration not at start of external entity
Blank line before XML declaration
XML parsing error: <unknown>:199:7: not well-formed (invalid token)

I came up with a workaround that fixes this, here is a summary:
1. Install a plugin that changes the RSS feed paths
2. Write a script to download and cleanup the broken RSS XML files
3. Set up a cron job to update RSS twice an hour

1. Install a plugin that changes the RSS feed paths
Download and install the Feed Locations plugin. Once you enable it, you can access the settings for it in Admin by clicking Tools > Feed Locations. In the configuration screen, I set my feed locations for each feed type to these values:

RSS .92:  http://www.domain.com/rss/rss.xml
RDF (aka RSS 1.0):  http://www.domain.com/rss/rdf.xml
RSS 2.0:  http://www.domain.com/rss/feed.xml
Atom 0.3:  http://www.domain.com/rss/atom.xml
Comments RSS feed:  http://www.domain.com/rss/comments.xml

2. Write a script to download and cleanup the broken RSS XML files
Here is the script file I use to do the rss downloading and code cleanup. I call it ‘rssfeed.sh’. Modify BLOGADDRESS and FEEDPATH to the correct values for your hosting account:

#!/bin/sh
BLOGADDRESS=http://www.domain.com
FEEDPATH=/home/content/d/o/m/domain/html/rss

# NOTHING BELOW THIS LINE SHOULD NEED MODIFIED
# --------------------------------------------
FEEDFILE=${FEEDPATH}/feed.xml
RSSFILE=${FEEDPATH}/rss.xml
RDFFILE=${FEEDPATH}/rdf.xml
ATOMFILE=${FEEDPATH}/atom.xml
COMMENTSFILE=${FEEDPATH}/comments.xml
UBUNTUFILE=${FEEDPATH}/ubuntu.xml


# Remove existing FEEDFILE if it exists
if [ -f ${FEEDFILE} ];
then
   rm ${FEEDFILE}
fi
# Download broken FEEDFILE
wget -q ${BLOGADDRESS}/feed/ -O ${FEEDFILE}
# Remove blank line from beginning of file that breaks FEEDFILE
tail -n +2 ${FEEDFILE} > ${FEEDFILE}1
# Remove GoDaddy code injection from end of file that break FEEDFILE
head -n -2 ${FEEDFILE}1 > ${FEEDFILE}2
# Delete temp file
rm ${FEEDFILE}1
# Update feed url to use new feed.xml address
sed 's/\/feed\/\" rel=\"self\" type=\"application\/rss+xml\" \/>/\/rss\/feed.xml\" rel=\"self\" type=\"application\/rss+xml\" \/>/' ${FEEDFILE}2 >${FEEDFILE}
# Delete temp file
rm ${FEEDFILE}2


# Remove existing RSSFILE if it exists
if [ -f ${RSSFILE} ];
then
   rm ${RSSFILE}
fi
# Download broken RSSFILE
wget -q ${BLOGADDRESS}/feed/rss/ -O ${RSSFILE}
# Remove blank line from beginning of file that breaks RSSFILE
tail -n +2 ${RSSFILE} > ${RSSFILE}1
# Remove GoDaddy code injection from end of file that break RSSFILE
head -n -2 ${RSSFILE}1 > ${RSSFILE}
# Delete temp file
rm ${RSSFILE}1


# Remove existing RDFFILE if it exists
if [ -f ${RDFFILE} ];
then
   rm ${RDFFILE}
fi
# Download broken RDFFILE
wget -q ${BLOGADDRESS}/feed/rdf/ -O ${RDFFILE}
# Remove blank line from beginning of file that breaks RDFFILE
tail -n +2 ${RDFFILE} > ${RDFFILE}1
# Remove GoDaddy code injection from end of file that break RDFFILE
head -n -2 ${RDFFILE}1 > ${RDFFILE}
# Delete temp file
rm ${RDFFILE}1


# Remove existing ATOMFILE if it exists
if [ -f ${ATOMFILE} ];
then
   rm ${ATOMFILE}
fi
# Download broken ATOMFILE
wget -q ${BLOGADDRESS}/feed/atom/ -O ${ATOMFILE}
# Remove blank line from beginning of file that breaks ATOMFILE
tail -n +2 ${ATOMFILE} > ${ATOMFILE}1
# Remove GoDaddy code injection from end of file that break ATOMFILE
head -n -2 ${ATOMFILE}1 > ${ATOMFILE}2
# Delete temp file
rm ${ATOMFILE}1
# Update feed url to use new feed.xml address
sed 's/\/feed\/atom\/" \/>/\/rss\/atom.xml" \/>/' ${ATOMFILE}2 >${ATOMFILE}
# Delete temp file
rm ${ATOMFILE}2


# Remove existing COMMENTSFILE if it exists
if [ -f ${COMMENTSFILE} ];
then
   rm ${COMMENTSFILE}
fi
# Download broken COMMENTSFILE
wget -q ${BLOGADDRESS}/comments/feed/ -O ${COMMENTSFILE}
## Remove blank line from beginning of file that breaks COMMENTSFILE
tail -n +2 ${COMMENTSFILE} > ${COMMENTSFILE}1
# Remove GoDaddy code injection from end of file that break COMMENTSFILE
head -n -2 ${COMMENTSFILE}1 > ${COMMENTSFILE}2
# Delete temp file
rm ${COMMENTSFILE}1
# Update feed url to use new comments.xml address
sed 's/\/comments\/feed\/\" rel=\"self\" type=\"application\/rss+xml\" \/>/\/rss\/comments.xml\" rel=\"self\" type=\"application\/rss+xml\" \/>/' ${COMMENTSFILE}2 >${COMMENTSFILE}
# Delete temp file
rm ${COMMENTSFILE}2

In your webspace, create a directory called ‘scripts’ and a directory called ‘rss’. Once you’ve created ‘rssfeed.sh’, upload it to the ‘scripts’ directory. Make the file executable – you can do this with your FTP client by setting the permissions to 755, or you can do this in the file manager that GoDaddy provides.

3. Set up a cron job to update RSS twice an hour
Log into your GoDaddy hosting control panel:
http://www.godaddy.com
Click Hosting > My Hosting Accounts > Manage Accounts

Click Content > Cron Manager > Create Cron Job

Cron Job Title: Update Feed
Command: Browse to the /scripts/rssfeed.sh file that you created
Frequency: Hourly
Minute: x:00
Click Custom.
Checkmark “Run twice an hour”
Click Save.

Note – my cron job didn’t start working as scheduled right away, it took some time for the job to go into effect and start processing for me.

Once you complete all these steps you should have working RSS that updates every 30 minutes. Your main RSS feed address (RSS 2.0) will be http://www.domain.com/feed/feed.xml. You can test it by clicking the RSS icon that shows up in your Firefox address bar when you visit your blog.

Note – These instructions assume that the address for your blog is the root of your domain (http://www.domain.com/). Replace all instances of ‘domain.com’ with your actual web address. If you blog resides in a different directory, such as http://www.domain.com/blog/, you should adjust all paths accordingly (http://www.domain.com/blog/feed/feed.xml for example).

21 thoughts on “Fix broken WordPress RSS in GoDaddy Free Hosting Accounts

  1. Starmancer

    Followed each step. The only part I was unclear on was the ‘feedpath’ in step 2. Not sure how to find the correct path, but I’m also using a free godaddy account, so I just left the path the same as yours. I’m still getting a feedburner error, though :(

    Error getting URL: 404 – null http://8mup.com/feed/feed.xml {X-Powered-By=[ModLayout/3.2.1], Connection=[Keep-Alive], null=[HTTP/1.1 404], Date=[Fri, 20 Feb 2009 23:03:31 GMT], Keep-Alive=[timeout=15, max=100], Pragma=[no-cache], Server=[Apache], Content-Type=[text/html], Transfer-Encoding=[chunked], Cache-Control=[no-cache]} GET

    It’s been about 20min since creating the cronjob, so maybe that still needs to kick in. The only other thing I can think that might be causing it, is where I created the “scripts” and “feed” folders. I put them in the root.

    Hope you can help, and thanks for writing a great article.

    Reply
  2. Sam Lesher

    Starmancer: When I go to your normal feed URL, I don’t get the broken XML:

    http://8mup.com/feed/

    I’ll check again in a bit to see if something is still waiting to batch through on GoDaddy. But, if that URL is broken that could cause a problem because the script downloads the broken XML and fixes it.

    Reply
  3. Sam Lesher

    I see that your default feed address now works (http://8mup.com/feed/). I bet if you set up that cron job now it will probably start working.

    As for how to find the correct ‘feedpath’, there’s probably an easier way, but here’s how I did it:

    Create a file called ‘test.php’. Enter this single line into that file, save it, and upload it:
    <?php include('blah'); ?>

    Access ‘test.php’ via a browser. It should give an error message that says something like:

    Warning: include(blah) [function.include]: failed to open stream: No such file or directory in /home/content/u/s/e/username/html/test.php on line 1

    Your feedpath is that path from the error + feed:
    /home/content/u/s/e/username/html/feed

    Let me know how you make out.

    Reply
  4. Bandy

    Hello, Thanks for the tutorial, but I am kind of confused on one thing.. I downloaded the RSS feed locator plugin, but I have no idea on what to type in as the locations.. I don’t have a feed folder or a rss folder. and when I change the permalinks in wordpress to http://www.domain.com/yr/mo/day/article it gives me 404 error, even with the feed, what it doees is now it goes to http://www.domain.com/feed url but also gives me the 404 error since there’s no “feed” folder. My question now is do I keep the default values (even in the feed locator plugin)?

    Sorry for the long comment, and thanks in advance.

    Reply
  5. Bandora

    Hello,

    I am having trouble with setting this up. I did write the script and I did do the to find the feedpath.. and I did set up the Cron job in godaddy.. But the only part that I am having trouble in is setting up the feed or the rss folder and have the xmls in it!

    I downloaded the plugin and I set everything like how you had on top, changed the domain.com to my domain name. But still no go. What do I have to do to make it work? I am not really that experienced with this so if you kindly help me with it step by step that would be great.

    Reply
  6. Pingback: 解决godaddy免费空间下feed出错的问题 | Happy SA

  7. BBuzzard

    Sam – I followed this step by step but it is not working and have no idea why. All I can tell you is that there is no xml file being put in the rss folder by the cron job.

    Hopefully you can help. Thanks.

    Reply
  8. BBuzzard

    I had it working, now GoDaddy changed ads or something and it is no longer working. Is it possible you can update this post, author?

    Thanks

    Reply
  9. slayer

    nice post but i have still error in feed.xml see at last this tag is missing which is break my feed
    please tell me how to add this tag and where?
    in rssfeed. or wp-rss.php, wp-rss2.php, feed.php

    where ?

    Reply
  10. Pingback: godaddy免费空间wordpress后台错误的解决:(1)feed错误的解决方案 - zuoshangs

  11. mmoore

    I have recently purchased a shared host package with Godaddy and I have been un-able to get any rss feeds to display on this paid account.
    I don’t get any path or code errors, just blank display for rss feeds. I am using mylastrss and set the cache and sub folder permissions to 777. I can use this code on other hosts without alteration and it works fine…but on Godaddy… nothing but blank display, any ideas as to the cause of this problem?

    thanks

    Reply
  12. Elly66

    Thank you. I have solved the problem.

    When I first read your post, I was a little bit confused. In the second last paragraph,you wrote,’Once you complete all these steps you should have working RSS that updates every 30 minutes. Your main RSS feed address (RSS 2.0) will be http://www.domain.com/feed/feed.xml.’ It should be “http://www.domain.com/rss/feed.xml” instead of “http://www.domain.com/feed/feed.xml”.

    There is an easy way to find the feed path. In the home page of the hosting control center, there is an account summary in which shows the absolute hosting path.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>