properly handle more complex URLs inside the CGI script