Your player can redirect ranged and spell attacks.
PHB 193 is clear that "attack" encompasses melee, ranged, and spell attacks:
Whether you’re striking with a melee weapon, firing a weapon at range, or making an attack roll as part of a spell, an attack has a simple structure.
PHB 194 goes on to specify that an "attack" involves an attack roll:
When you make an attack, your attack roll determines whether the attack hits or misses. To make an attack roll, roll a d20 and add the appropriate modifiers.
The text of the feat, as you quote, simply says "attack". It doesn't make any exceptions based on the size of the mount.
However, spells that don't require attack rolls, such as Magic Missile or spells that require saves, are not "attacks" for this purpose.
Additionally, the MM is full of examples of large, dragon-like creatures specifically called out as mounts. For instance, the Wyvern (CR 6) can be used as a mount (MM 303):
A wyvern can be tamed for use as a mount, but doing so presents a difficult and deadly challenge.
In general, riders and mounts can be targeted like any other creature
The rules for Mounted Combat don't specify how targeting works for the Attack action (or any other action) because targeting riders and mounts is no different that targeting any other creature, with the exception of opportunity attacks.
Whether you can target either, neither, just the rider, or just the mount has nothing to do with their status as rider and mount, rather it depends on many other circumstantial factors, the most common of which are by far range and total cover.
From Making an Attack:
Choose a target. Pick a target within your attack's range: a creature, an object, or a location.
From Total Cover:
A target with total cover can't be targeted directly by an attack or a spell, although some spells can reach such a target by including it in an area of effect. A target has total cover if it is completely concealed by an obstacle.
For example:
- If your attack has a 5' range and you are a medium creature standing at the feet of a T-Rex, then you can target the T-Rex, but you probably1 can't target its rider.
- If you can see a rider peeking over a wall, but its mount has total cover, then you can target the rider with an attack, but not the mount.
Opportunity attacks
The rules for Opportunity Attacks state that:
You can make an opportunity attack when a hostile creature that you can see moves out of your reach. To make the opportunity attack, you use your reaction to make one melee attack against the provoking creature. The attack occurs right before the creature leaves your reach.
And that:
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.
The rules for Controlling a Mount also state that:
if the mount provokes an opportunity attack while you’re on it, the attacker can target you or the mount.
In short, a rider never provokes your opportunity attack when it moves using its mount's movement. But if a mount provokes your opportunity attack, then you can choose to target the rider instead of the mount, despite the fact that the rider did not provoke said opportunity attack.
However, this does not mean you can target a rider regardless of all other factors such as range or total cover. For example, opportunity attacks occur retroactively just before the target leaves your reach, but if the rider was never within your reach to begin with, then you can't possibly attack the rider.
- The height of creatures and the location of a rider atop a mount are often not well defined so there is room for DM adjudication.
Best Answer
Sure
Unless the source of your advantage is dependent on something that doesn't apply to attacks of opportunity (like taking the "Attack Action"), you can absolutely get advantage on an attack of opportunity.
In the case of your specific example, the Mounted Combatant Feat states that (PHB, p. 168):
There's nothing in that description that explicitly rules out an opportunity attack. As long as your opportunity attack fulfilled all the above criteria, it would get advantage.