RouteStuff.php

<?php

function normalizeUrl($url){
        $ext = pathinfo($url,PATHINFO_EXTENSION);
        $hiddenExts = ['php'];
//
        if ($removeDoubleSlash=true){
            while (strpos($url,'//')!==FALSE)
                $url = str_replace(['////','///','//'],'/',$url);
        }
        if ($toLowerCase=true){
            $url = strtolower($url);
        }
        foreach ($hiddenExts as $hiddenExt){
            $hiddenExt = '.'.$hiddenExt;
            $hideIt = true;
            if ($hideIt
            &&strtolower(substr($url,-(strlen($hiddenExt))))==strtolower($hiddenExt)){
                $pos = strrpos($url,$hiddenExt);
                $remainder = substr($url,$pos+strlen($hiddenExt));
                $url = substr($url,0,$pos).$remainder;
                $ext = '';
            }
        }
        if ($forceTrailingSlash=true
            &&substr($url,-1)!=='/'){
            $url .= '/';
        }
        if ($removeTrailingSlashIfExt=true
        &&$ext!=''){
            while (substr($url,-1)==='/')
                $url = substr($url,0,-1);
//
        }
//
        return $url;
    }