Yes, but not while flanking with a reach weapon.
A feat that (mostly) does what you are looking for is called Archon Justice, the capstone of the Archon Style tree:
While using this style, as a move action, you can protect adjacent allies from a single opponent that you currently threaten. This grants adjacent allies a +2 dodge bonus to AC against that opponent’s next melee attack (as long as that attack comes before the beginning of your next turn), but causes you to take a –2 penalty to AC against that opponent until your next turn. The dodge bonus against the designated opponent’s attacks persists even if your allies move away from you.
The penalty to AC for using Archon Style to grant nearby allies a bonus to AC against a single opponent decreases to –1. Once per round while using Archon Style, when you have at least one hand free or when wielding a shield, you can divert one melee weapon attack targeting an adjacent ally to yourself. After resolving the attack, the ally you protected can make an attack of opportunity against the diverted opponent. You expend no action to divert the attack, but you must be aware of it and must not be flat-footed. You must choose to divert the attack after the opponent has declared the melee attack, but before the attack roll is rolled.
You no longer take a penalty to AC for using Archon Style to grant nearby allies a bonus to AC, and you can activate this effect as a swift action or a move action. Whenever you take damage from an attack you diverted to yourself using Archon Diversion, each ally threatening the attacking creature can make an attack of opportunity against that creature.
This combo has prerequisites of BAB +8, Combat Expertise and Combat Reflexes, plus Archon Style and Archon Diversion, but no class requirements. It also won't work unless you're adjacent to your ally.
You are your own ally, so not only do you get an AoO for this, so does your buddy being attacked, and any other ally in melee range.
You could also accomplish this for just yourself with just the second feat in the tree, Archon Diversion, by playing a class that gets a parry/riposte mechanic such as a swashbuckler or duelist, then successfully parry-riposting the diverted attack.