Force all links to be absolute I've a custom module I'm sending the content of node and views by email. The module first render the node/view and wrap the results around common template.

But when my views and node content are build, they contain links are relatives. I'm looking for a way to force these links to be absolute (ie. with domain and protocol).

The url() and l() functions can be used to output absolute links, but I don't see a way to force this behavior on all links. I'm planning to process the content as an HTML string to extract all links and complete the URL when required. But this doesn't seem very efficient.

Is there another way to ensure absolute URL ?

Here is the code used to render the content for nodes and views:

//For nodes
$node = node_build_content($node, FALSE, FALSE);
$node-&gt;body = drupal_render($node-&gt;content);
unset($node-&gt;teaser);
node_invoke_nodeapi($node, 'alter', FALSE, FALSE);
$content = $node-&gt;body;

//For views
$content = $view-&gt;preview($display_id, $arguments);
Have a look at this module: Pathologic


  Pathologic is an input filter which can correct paths in links and
  images in your Drupal content in situations which would otherwise
  cause them to “break;” for example, if the URL of the site changes, or
  the content was moved to a different server. Pathologic can also solve
  the problem of missing images and broken links in your site’s RSS
  feeds. See more example use cases on the documentation page.