Don't use the calculated path if it's not a filename
Fixed cgi execution