Doesn't really matter that much (servers should be able to canonicalise URLs), but I do see why it would be desirable. I thought there was a canonical URL function, but it turns out it was fir filepaths ([man]realpath[/man], as it happens).
So...
$url = preg_replace('![^/]+/\.\./!', '', $url);
$url = str_replace('./', '', $url);
Notice that it assumes that the URL is a sensible one (e.g., http://www.example.com/../silly.html is not sensible).