What type of insulation would be better for under the sub floor.
There would be a dirt floor under the building and would I be better off with rigid foam or fiberglass?
Rigid foam.
Rigid foam is good but is difficult to install tightly enough to stop air infiltration----you may have to fill small gaps with spray foam.