Posted By

weboholic on 10/26/10


Tagged

url regexp


Versions (?)

Root Relative URLs


 / Published in: PHP
 

URL: http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/

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.