/** * Rewrite URL with new format * * @param string $url * @param string $format */ public static function updateUrlFormat($url, $format) { $exploded = parse_url($url); $path = $exploded['path']; $splitted = explode('.', $path); if (count($splitted) > 1) { array_pop($splitted); $path = join('.', $splitted); } return RestoUtil::baseUrl($exploded) . $path . '.' . $format . (isset($exploded['query']) ? '?' . $exploded['query'] : ''); }