You can force an attack targeted at your mount to target you instead.
Choosing a target is the first step of the Attack action and it happens before any roll (see PHB p. 194). Therefore, this needs to be declared before the attack roll.
CC takes the hit.
The horse is the one provoking the attack of opportunity, no matter who the attack eventually targets.
After the attack of opportunity has been provoked, the troll is simply making a melee attack against a target - and the Mobile feat does not provide you immunity to being targeted by melee attacks.
Some context about opportunity attacks, mounted combat, and the mobile feat:
When riding a mount, you are moved by someone without using your movement, action, or reaction, and as such you do not provoke an opportunity attack.
You also don’t provoke an opportunity attack when you teleport or when someone or something moves you without using your movement, action, or reaction. (Chapter 9, Making an Attack - PHB)
Mounted combat also specifies that an attacker can choose to target you with an opportunity attack even when you don't provoke one, if your mount provokes an opportunity attack.
if the mount provokes an opportunity attack while you’re on it, the attacker can target you or the mount. (Chapter 9, Mounted Combat - PHB)
So in actuality, the Mobile Feat provides no real benefits while mounted:
You are using your mount's speed to move, so the speed increase does not matter;
Your mount would be the one taking the dash action, not you;
You already do not provoke opportunity attacks when mounted.
And aside from that, the discerning rider might want to have his mount Disengage as its action, avoiding this situation entirely.
The rider gets no benefits from total cover because a redirected attack is not a direct attack but an indirect one; alternatively, this is a case over specific over general
The rules on Cover state:
I would say that redirecting an attack from your mount to yourself is not, in any way, making it a direct attack against you. The attack has indirectly targeted you and thus total cover provides no benefits.
Unfortunately covers do not stack:
Thus having total cover does not also give you ¾ cover. This means that the rider will be benefitting from no forms of cover whatsoever and the attack roll will happen as normal. Though what counts as the "most protective degree" could be argued to be ¾ cover that's something I'm less sure of and is somewhat explained in the question "What constitutes the most protective degree of cover?".
Alternatively you could explain this as the Mounted Combatant feat allowing you to target somebody even if they do have total cover. This would just be an example of specific over general where normally you can't target somebody with total cover but the Mounted Combatant feat specifically forces the rider to be targeted (barring any even more specific rule). Note that the feat says the attack targets you, not that it targets you only if the attack could otherwise do so legally. Thus the feat results in you being targeted by the attack even if it would usually be illegal.
This angle is the approach taken in user jgn's answer