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
http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/

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
PHP