Root Relative URLs


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. function make_href_root_relative($input) {
  2. return preg_replace('!http(s)?://' . $_SERVER['SERVER_NAME'] . '/!', '/', $input);
  3. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.