How to make a "relative-path" template include-fil
Posted: Wed Aug 27, 2003 5:29 pm
I made a couple template files (top and bottom), which I include in the beggining and end of each web page. Right now, I create a URL prefix that I stick in front of each file reference, whether it be a link or image.
Here's the code for how I do this:
This method solved my initial problem, which was that pages that were in a sub directory would not work, because the path wasn't relative anymore.
The drawback of this method is that if I have 50 references to images or links that use this $RelURL, then the file size increases significantly.
Any ideas would be appreciated!
Here's the code for how I do this:
Code: Select all
<?php
if( isset($_SERVER['HTTP_REFERER']) ) { $CurrentURL = $_SERVER['HTTP_REFERER']; } else { $CurrentURL = ''; }
$FindInURL = 'https';
$URLSecure = strpos($CurrentURL, $FindInURL);
if ($URLSecure === false) {
$RelURL = 'http://www.mysite.com/';
} else {
$RelURL = 'https://www.mysite.com/';
}
?>The drawback of this method is that if I have 50 references to images or links that use this $RelURL, then the file size increases significantly.
Any ideas would be appreciated!