The best way to prevent the subfloor from moisture is to install a vapor barrier. A vapor barrier is a material that helps to prevent moisture from passing through. In addition, installing underlayment over vapor barrier will bring additional protection.