The pit is extradimensional space and entire unto itself. It does not connect to anything. E.g. if you have 2 pits next to each other, you cannot go from one to the other. You cannot "dig" through the walls of the pit, use "merge into stone", "passwall", or anything like that to get out. Aside from the spell requiring "sufficient space" (20'x20'), casting it "under" a door, would simply have you look up from the bottom and see the area you came from, as it's not a physical pit, but extradimensional.
If you cast it on a 20'x20' table, you could look down 20-30' into the pit and see a bottom that far away, but if you looked under the table, you would see open space through to the other side of the table.