My celiac hubby went through something similar & we eventually solved it by adding relevant (to the meal ingredients) digestive enzymes to his mealtimes. It needs to be every meal, every day. Now that he's in good control he usually skips them for snacks, though at first, he dosed for them, too. We use two multi-types, one with a broad selection and one that focuses on bean-related needs. He sometimes uses just one but since a lot of gluten-free breads & pastas use bean and/or pea flours he often needs both.
Along with those, he gets probiotic yogurt (twice a day until control, once a day thereafter), or a highly active probiotic supplement. When his gut goes off the deep end he gets a 3-month course of heavy-duty prescription probiotics. The difference has been astonishing! We had to figure all this out with trial & error, and the docs- even the nutritionist- weren't very useful. To their credit, once we showed them it worked they've been very supportive.
Digestion requires a lot of coordinating processes, among them enzyme production in various organs, much if it in the gut directly. Here're the basics: http://www.bbc.co.uk/schools/gcsebitesize/science/add_edexcel/common_systems/digestionrev3.shtml
And here're more details (note, this guy's trying to sell you stuff, but the info & studies he links to appear legit): https://bengreenfieldfitness.com/article/nutrition-articles/how-to-choose-a-digestive-enyzme/
For my hubby & lots of others with severe gut damage, the body's ability to produce enzymes in the gut is permanently impaired to some degree. This leads not only to GI symptoms but also to micronutrient deficiencies that can be hard to test for but impact energy & health now & over time. Adding enzymes back is the only way to improve function. At the least, it won't hurt to try for 3-4 weeks. Just be sure to be consistent! My hubby slacks off now & then and his symptoms come right back.