I've been activly finding counters to cavalry and it seems this is by far the best one.

Stretch your infantry out at least 6 ranks deep, if there aren't enough men in the unit to do so place a unit of infantry IMMEDIATLY behind this unit. Make sure you place units in guard mode. Next thing is just stand there and receive the charge.

The key as many people have stated it seems is just to have enough men as fodder that they just stay there and take it and bog the cavalry down. You'll take massive casualties but as long as you stop the cav unit you're going to hurt it real bad.

Archers and crossbowmen are excellent for softening up cav before they hit your lines as well. Seems the best counter for cav is well, cav. Been playing an amazing campaign as the Moors, who are a really fun faction to play, much more challenging this time around as you can't just churn out tons of Almohad Urban Militia from the beginning and take over iberia right away like in Medieval. Well I was sieging Lisbon and the managed to kill the King of Portugal when he attacked my besieging army, drew him in to attack my spearwall and had to use rally as he almost routed them but I swung my general around behind and surrounded him. Guess that's how you do it this time around.