Anthropophilic species (“commensal” species) that are completely dependent upon anthropic habitats experience different selective pressures particularly in terms of food than their noncommensal counterparts. Using a next‐generation sequencing approach, we characterized and compared the gut microflora community of 53 commensal Rattus rattus and 59 noncommensal Rattus satarae captured in 10 locations in the Western Ghats, India. We observed that, while species identity was important in characterizing the microflora communities of the two Rattus hosts, environmental factors also had a significant effect. While there was significant geographic variation in the microflora of the noncommensal R. satarae, there was no effect of geographic distance on gut microflora of the commensal R. rattus. Interestingly, host genetic distance did not significantly influence the community in either Rattus hosts. Collectively, these results indicate that a shift in habitat is likely to result in a change in the gut microflora community and imply that the gut microflora is a complex trait, influenced by various parameters in different habitats.