how do I Replace a ceiling fan with dimmer switch for lights and on/off switch for fan
I,ll describe the process of elimination that ThreePhaseEel describes.  

First, you connect earth to earth, because it's a world standard that green, green/yellow, or bare is always earth.  So that's easy. 

If neutral is present, it must be white.   Neutral must by nature be present on both sides here, so the whites must be neutral. Connect them, done.  

That leaves two colors from the wall and two from the fan.  Colored wires must be hot.  There are only 2 ways to hook them up.  We're not sure, but it won't be destructive to try one way and see.