Fix port detection

Some URLs like http://www.mysite.com/redirect?url=http://www.mysite.com/page are not correct parsed.
To correctly detect the port, first you should check if the ':' is before the path.