I don’t know why it was so hard to find some code to do this. I did a few google searches and couldn’t find a simple solution so here’s one that works…
function mh_UrlToFilePath($url="") {
$sServerName = $_SERVER["SERVER_NAME"];
$sDocRoot = $_SERVER['DOCUMENT_ROOT'];
$sUrl = substr($url, 0, strpos($url, "?")); // remove querystring
$sFilePath = substr($sUrl,strpos($sUrl,$sServerName)+strlen($sServerName));
$sFilePath = $sDocRoot . $sFilePath;
$sFilePath = str_replace("/", "\", $sFilePath);
return $sFilePath;
}