Posted By

weboholic on 10/26/10


url regexp

Versions (?)

Root Relative URLs

 / Published in: PHP


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

  1. function make_href_root_relative($input) {
  2. return preg_replace('!http(s)?://' . $_SERVER['SERVER_NAME'] . '/!', '/', $input);
  3. }

Report this snippet  

You need to login to post a comment.