Return to Snippet

Revision: 34656
at October 26, 2010 19:37 by weboholic

Initial Code
function make_href_root_relative($input) {
    return preg_replace('!http(s)?://' . $_SERVER['SERVER_NAME'] . '/!', '/', $input);

Initial URL

Initial Description
For several reasons, including portability, reducing download size, and general code neatness, I like to make all links within a website root relative.

Initial Title
Root Relative URLs

Initial Tags
url, regexp

Initial Language