1

Is it possible to make a static RSS feed file that can be moved from server to server without change? It appears that relative links are not fully supported in RSS, but the latest info I've found is quite old; something javascripty would work in HTML, but not in RSS XML.

Background: I'm working with an HTML publishing project that generates static RSS feed files for some lists of resources. To update, you'd re-publish the static file to the same location. One export option is to save to your filesystem and then transfer to the server manually, but for RSS feeds we're currently requiring the destination URL to be entered on export.

Michael Brewer-Davis
  • 14,018
  • 5
  • 37
  • 49
  • It's not that relative links aren't supported in RSS. Relative links are exactly that, relative to the host they are on. It's not an RSS limitation, it's how HTTP works. If you want those links to be portable, then you need to make them absolute URLs. – Josh Deeden Mar 08 '11 at 17:15
  • I actually want them to be relative to the host--all of my linked resources are in the same export directory as the feed file. I've just seen information that these don't work reliably. – Michael Brewer-Davis Mar 08 '11 at 17:18
  • **Related:** [Link to RSS/Atom feed, relative, doesn't work in Firefox](http://stackoverflow.com/q/4438794/1497596) – DavidRR Sep 17 '14 at 18:20

1 Answers1

0

In the script that generates your RSS, you could do something like this:

<?php
    // example: $_SERVER['HTTP_HOST'] = 'mysite.com';
    $mysite = 'http://' . $_SERVER['HTTP_HOST'];

    // the page you're linking to
    $thislink = 'mypage.html';

    /* code that generates your RSS */

    // output the link
    echo '<a href="' . $mysite . '/' . $thislink . '">';

    /* more code that generates your RSS */
?>

Output:

<a href="http://mysite.com/mypage.html">
drudge
  • 35,471
  • 7
  • 34
  • 45
  • This is just a basic setup, I'm sure there's better methods. – drudge Mar 08 '11 at 18:47
  • Alas, I'm trying to generate static files, not PHP. For manually uploaded web sites, I can't assume server side scripts. – Michael Brewer-Davis Mar 08 '11 at 21:48
  • Well, you can't use JavaScript within RSS, and I'm doubtful that `` would work. Sounds like you may need to re-think what you're trying to do, and what tools you want to use. – drudge Mar 08 '11 at 22:19