Skip to content

Instantly share code, notes, and snippets.

@battis battis/path_to_url.php
Last active Jul 30, 2017

Embed
What would you like to do?
Apache 2’s CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT Variables
$path = __FILE__;
$url = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ?
'http://' :
'https://'
) .
$_SERVER['SERVER_NAME'] .
$_SERVER['CONTEXT_PREFIX'] .
str_replace(
$_SERVER['CONTEXT_DOCUMENT_ROOT'],
'',
$path
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.