Sahih al-Bukhari 2529
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
الأَعْمَالُ بِالنِّيَّةِ، وَلاِمْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ، فَهِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ، وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيبُهَا، أَوِ امْرَأَةٍ يَتَزَوَّجُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ "
Narrated `Umar bin Al-Khattab:
The Prophet (ﷺ) said, "The (reward of) deeds depend on intentions, and every person will get the reward according to what he intends. So, whoever migrated for Allah and His Apostle, then his migration will be for Allah and His Apostle, and whoever migrated for worldly benefits or for marrying a woman, then his migration will be for what he migrated for." (See Hadith No. 1, Vol. 1)
Full reference and source
Sahih al-Bukhari 2529 In-book : Book 49, Hadith 14 USC-MSA web (English) : Vol. 3, Book 46, Hadith 706 (deprecated)
View source on Sunnah.com (opens in a new tab)