ElggRewriteTester::guessSubdirectory PHP Method

guessSubdirectory() public method

Guess if url contains subdirectory or not.
public guessSubdirectory ( string $url ) : string | boolean
$url string Rewrite test URL
return string | boolean Subdirectory string with beginning and trailing slash or false if were unable to determine subdirectory or pointing at root of domain already
    public function guessSubdirectory($url)
    {
        $elements = parse_url($url);
        if (!$elements || !isset($elements['path'])) {
            return false;
        }
        $subdir = trim(dirname($elements['path']), '/');
        if (!$subdir) {
            return false;
        } else {
            return "/{$subdir}/";
        }
    }