Why Relative Links in an RSS Feed Break in Some Readers

Learn why relative URLs in RSS feeds can fail in readers, how redirects and feed hosts affect them, and how to check links, images, and enclosures.

Published
Reading time
6 min read
Why Relative Links in an RSS Feed Break in Some Readers
On this page

Relative URLs in an RSS feed can work on your website but lead readers to the wrong page or image when the feed is syndicated. The problem is the base URL: a reader needs one to turn a relative reference into a complete destination, and it may not use the URL you expected.

This guide shows how to diagnose the problem and make article links, images, and enclosures more portable across RSS and Atom readers.

Key Takeaways

  • A relative URL needs a base URL. A feed reader may resolve it against the feed location rather than your website.
  • Use absolute HTTPS URLs for article links, embedded images, and enclosures whenever possible.
  • Check the actual feed response after redirects, not just the article page or the feed URL shown in your CMS.
  • Validate the feed and test it in a reader. This article's examples were not tested in either, so verify the behavior in your own setup.

Why relative URLs in an RSS feed break

Suppose your website is https://www.example.com/, but your feed is served from https://feeds.example.com/feeds/updates.xml. An article link in the feed contains:

/posts/summer-guide

If a reader uses the feed URL as its base, the link resolves to https://feeds.example.com/posts/summer-guide. If it uses the website URL as its base, it resolves to https://www.example.com/posts/summer-guide. Only the second destination may contain the article.

A relative reference without a leading slash is also sensitive to the base path. For example, posts/summer-guide resolved against https://feeds.example.com/feeds/updates.xml points under /feeds/, not necessarily at the website root.

Readers differ in how they process feed fields and embedded HTML, and a feed or its content can also declare a base. Do not rely on every reader choosing the same base or interpreting the same declaration.

Advertisement

Inspect the raw feed your subscribers receive. Search for destinations that begin with /, ./, or ../, or with a path such as images/photo.jpg rather than a scheme and host. Check these locations:

  1. Article links: The RSS item link or an Atom entry's link element.
  2. Embedded content: Links and image sources inside an RSS item description or Atom content. This includes HTML attributes such as href, src, and potentially srcset.
  3. Enclosures: Media URLs supplied as RSS enclosures or Atom enclosure links.

The RSS 2.0 specification and the Atom Syndication Format RFC were not available to consult for this article. They should be checked for the exact requirements of each field and format; the practical advice here is to publish complete destinations rather than depend on relative-reference handling. Atom's xml:base, for example, can provide base information, but it is not a substitute for checking how your intended readers handle embedded content.

Before and after: RSS item

This illustrative item uses relative destinations for an article, image, and enclosure:

<item>
  <title>Summer guide</title>
  <link>/posts/summer-guide</link>
  <description><![CDATA[
    <p>See our <a href="/posts/summer-guide">guide</a>.</p>
    <img src="/images/summer.jpg" alt="Summer landscape">
  ]]></description>
  <enclosure url="/media/summer.mp3" length="512" type="audio/mpeg" />
</item>

Publish complete destinations instead:

<item>
  <title>Summer guide</title>
  <link>https://www.example.com/posts/summer-guide</link>
  <description><![CDATA[
    <p>See our <a href="https://www.example.com/posts/summer-guide">guide</a>.</p>
    <img src="https://www.example.com/images/summer.jpg" alt="Summer landscape">
  ]]></description>
  <enclosure url="https://media.example.com/summer.mp3" length="512" type="audio/mpeg" />
</item>

These are item fragments, not complete feeds. The domains and the enclosure length are illustrative: use your actual public URLs and the media file's actual length in bytes. Ensure the declared media type matches the file.

For Atom, apply the same destination check to entry links, enclosure links, and HTML in content. Attribute syntax differs: for example, an Atom link uses an href attribute. Preserve the rest of the element and its relationship information when changing a destination.

Check redirects and HTTPS

A feed subscription URL can redirect to a different path, host, or HTTPS address. The final feed location may affect how a reader resolves relative references. An image or article URL can redirect too, and readers may handle those redirects differently.

Use the final, intended public HTTPS URL in the feed where you control it. Then check that:

  • The subscription URL reaches the intended feed, including after any HTTP-to-HTTPS redirect.
  • The article, image, and enclosure destinations open without requiring an interactive login.
  • A redirect does not send an HTTPS destination back to an unwanted HTTP address or a different host.
  • Image and media URLs return the expected content, not an error page or a login page.

Absolute URLs remove ambiguity about the initial destination; they do not guarantee that redirects, permissions, or reader policies will work.

Advertisement

Validate and test in a reader

Use a staging feed or a feed you are authorized to test. These steps have not been performed for the example above:

  1. Fetch the published feed. Open its subscription URL and inspect the XML returned after redirects. Confirm that the article, image, and enclosure values are the ones you intended to publish.
  2. Run a feed validator. Submit the public feed URL, or use a validator that accepts pasted XML. Review both syntax and field-specific errors; a well-formed XML document is not necessarily a valid feed.
  3. Check representative destinations. Open at least one article and image URL directly. Request an enclosure and check its response, media type, and size against the feed metadata. If using command-line HTTP tools, inspect the redirect chain as well as the final response.
  4. Subscribe in at least one reader. Use the same subscription URL that readers receive. Open the article, inspect the image, and try the enclosure. Note the reader and the feed URL you tested so you can repeat the check after changes.
  5. Test a redirect case. If subscribers use an older HTTP URL or a feed URL on another host, test that subscription path too—not just the final feed address.

A successful check in one reader does not establish compatibility with all readers. If your audience uses several important clients, repeat the subscription test in each. Avoid submitting private feeds, credentials, or token-bearing URLs to a public validator.

Common Mistakes

  • Fixing only the item link. The article may open correctly while an image, inline link, or audio file still points to the feed host.
  • Assuming the website and feed share an origin. A feed proxy, publishing platform, or CDN can serve the feed from a different host or path.
  • Prepending the website origin to every value blindly. A relative path may be intended for a media host, and an already absolute URL should not be rewritten. Handle HTML and srcset as structured content rather than using a broad text replacement.
  • Testing only in a browser. A browser rendering the XML or article page does not reproduce every feed reader's handling of embedded content.
  • Publishing placeholder enclosure metadata. The enclosure URL, byte length, and media type should describe the actual file.

Best Practices

Configure your feed generator or CMS to emit canonical, public HTTPS destinations for each resource. Use the appropriate host for each one: the website for articles, and your actual image or media host where applicable. Escape URLs correctly for their XML or HTML context, especially when a query string contains &.

After changing your domain, feed host, CDN, or redirect rules, inspect the generated feed and repeat the validator and reader checks. Cached copies can delay when subscribers see an updated feed, so allow for that when troubleshooting.

Conclusion

Relative references become fragile when a feed travels away from the website that produced it. Publish complete destinations, inspect the feed after redirects, and verify article, image, and enclosure behavior in a validator and the readers your audience uses.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.