They do not stack because the damage roll of Flames of Phlegethos is separate from any spell's damage roll
The first bullet of Flames of Phlegethos states:
When you roll fire damage for a spell you cast, you can reroll any roll of 1 on the fire damage dice and use the new roll.
And thus it can only apply to damage rolls of spells you cast. The other bullet however, states:
Whenever you cast a spell that deals fire damage you can ...cause flames to wreathe around you until the end of your next turn . .. any creature within 5 feet of you that hits you with a melee attack takes 1d4 fire damage.
The damage from this is not you casting a spell, it simply happens when you are hit by a melee attack. The 1d4 additional damage is not part of the spell's damage because,Even though it does rely on the spell "causes flames to existwreathe around you" , it isthese flames are not considered part of the spell'sspell as they are not in its description. The extra 1d4 fire damage areThis let's us establish that the feat's own damage roll.
Because these dice arethe flames cause is not part of the spell's damage roll these. Thus the parts of thethis feat do not stack with each othercannot be used together because the additional 1d4 will always be its own damage roll, separate from any spell's.