Quadripedal Rigging: Twisted limbs
If the IK constraint isnt pointing at the pole target the right way, you might want to try changing the pole angle

also, looks like you need to recalculate the normals on your mesh because the leg looks flipped inside out.