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}/"; } }