The Holy Prophet of Allahu Ta'ala says : the acts depend on the intentions. The Hijrah of the person who mgrates to Allah & His Holy Messenger Sall Allahu Ta'ala Alaihi Wa Sallam, is to Allah and the Messenger and the hijrah of the person who migrates to the world, is to the world. one gets reward because of his good intention.