by Jeff Eaton on November 5, 2012 // Short URL

Module Monday: Pathologic

How to Tidy URLs and Relative Links When Moving From Dev to Go-Live (for Drupal 6 and 7)

Few things are as annoying as building something that works perfectly when you create it, but fails when you take it out of the lab. That's how site owners can often feel when content editors create piles and piles of Drupal nodes full of relative URLs in images and links. They look fine on the site, but if the content is syndicated via RSS or Atom, sent out in an email, or otherwise repurposed in another location, the links break. Even worse, hand-made links and images entered while the site is under development can easily point to the outdated "beta" URL. Who can save the day? Pathologic module, that's who.

Pathologic module's configuration options

Pathologic is an input filter -- to install it, you drop the module into your Drupal site and add it to one of your text formats -- Full HTML and Filtered HTML, for example. Whenever content is posted in a format configured to use Pathologic, it will scan the content for URLs and tidy them up. Relative URLs like /node/1 get turned into absolute ones like, URLs pointing to alternative versions of your site like are replaced with your public URL, and so on.

Pathologic can also standardize the protocol of links inside your site's content. If users edit content over a secure connection, for example, it's easy to mix links using the http:// and https:// protocols -- something that can lead to annoying warnings on some users' machines. For developers with exacting URL-correcting needs, it also supports custom URL modification hooks. Using those hooks, your site's custom fixes (replacing MP3 links with a URL on a different server, for example) can piggyback on Pathologic's configuration and logic.

Pathologic is an efficient workhorse of a module that solves an annoying problem efficiently. If you've run into problems with relative links and staging-server URLs breaking links and images on your RSS feeds, you owe it to yourself to check it out!

Jeff Eaton

Senior Digital Strategist

Want Jeff Eaton to speak at your event? Contact us with the details and we’ll be in touch soon.


Carson W


Jeff, was this Module Monday's pick influenced by your attendance at the BADCamp workshop on responsive email? :-)


Tom Hoogendyk

Works well with URL aliases

Thanks Jeff for highlighting this module. I use the pathologic module on every site I build. It's great. One of the things I like most about it is that you can enter links to pages using their node IDs (/node/2) and the link will be translated to its clean URL: either or Then, when someone decides to change the URL alias to about-us just before the site goes live, the previous links to the about page will all still work because pathologic translates them from the node ID to about-us instead of about.



Are you totally sure?

Is still possible to use latest pathologic versions for converting automatically node/NID links to the relative alias???????


Brandy Red

A simple module

Pathologic is a greate module. It can save you from a lot of problems. But not, in my opinion, the main problem. The main problem is that you allways should save your URLs as relative URLs. (Even if you are using wysiwyg-editors.)

This is what I do. I made my own module. This module strips out the domain name before the node is saved. In that way a node always contains relative URLs. The main hook in my module look like this:

function fxabs2rel_node_presave($node) {
$output = $node; //Variable to work with

//Get current domain name with path to Drupal folder
$current_domain = $_SERVER['HTTP_HOST'];
$http_domain = 'http://' . $current_domain . base_path();
$https_domain = 'https://' . $current_domain . base_path();

$search = array( $http_domain, $https_domain );

//For each field in current content type
foreach ($output as $key => $value) {
if ($key === 'body' || strpos( $key, 'field_' ) === 0 ) {

//Replace domain name whit "/"
if ( isset( $value['und'][0]['value'] ) ) {
$value['und'][0]['value'] = str_ireplace ( $search , '/' , $value['und'][0]['value'] );


$node = $output; //Output the content of our varibable

When using this module I am also using the Pathologic module to take care of the RSS issue, by converting "/" to current domain name, eg. "".

English is not my first language, so I hope this ake sence.