def remove_dot_segments(path):
    """
    Algorithm from RFC 3986. urllib.parse has this algorithm, but it's hidden in urljoin()
    This is a stand-alone version. Since this is working on a non-relative url, path MUST begin with '/'
    """
    if path[0] != '/':
        return path
    segments = path.split('/')
    segments[1:-1] = filter(None, segments[1:-1])
    resolved_segments = []
    for s in segments[1:]:
        if s == '..':
            try:
                resolved_segments.pop()
            except IndexError:
                pass
        elif s == '.':
            continue
        else:
            resolved_segments.append(s)
    return '/' + '/'.join(resolved_segments)
