Created
March 2, 2011 19:42
-
-
Save thomas-p-wilson/851572 to your computer and use it in GitHub Desktop.
Determines the path and url to the current file. Handles HTTPS and mod_rewrite.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define root path constant. $_SERVER['SCRIPT_FILENAME'] seems to survive | |
// redirects. | |
$root_path = dirname($_SERVER['SCRIPT_FILENAME']); | |
if(substr($root_path,-1) != '/') { | |
$root_path .= '/'; | |
} | |
define('ROOT_PATH',$root_path); | |
unset($root_path); | |
// Define root url constant | |
$root_url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; | |
$root_url .= $_SERVER['HTTP_HOST'] . '/'; | |
$root_url .= substr(ROOT_PATH, | |
strpos( | |
ROOT_PATH, | |
$_SERVER['DOCUMENT_ROOT'] | |
) + strlen($_SERVER['DOCUMENT_ROOT']) + 1); | |
define('ROOT_URL',$root_url); | |
unset($root_url); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment