开发者

Can an RSS file be made portable (with relative links or scripting)?

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 s开发者_如何转开发tatic 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.


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">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜