public static function encodeRelativeUrl($url)
    {
        $url = str_replace(DIRECTORY_SEPARATOR, '/', $url);
        $parts = explode('/', $url);
        foreach (array_keys($parts) as $key) {
            $parts[$key] = rawurlencode($parts[$key]);
        }
        return implode('/', $parts);
    }