the Fatwa Department Research Committee - chaired by Sheikh `Abd al-Wahhâb al-Turayrî
The Prophet (peace be upon him) said: “Do not undertake a journey except to three mosques: al-Masjid al-Harâm, my mosque, and al-Aqsâ Mosque.” [Sahîh al-Bukhârî (1864) and Sahîh Muslim (1397)]
What the hadîth is discussing – and Allah knows best – is someone undertaking a journey to the locality of a particular mosque or some other place as an act of worship in and of itself or in order to worship at a specific locality with the intent that the locality itself has some religious significance.
The three mosques mentioned in the hadîth are permitted as specific places to which a person can intend a journey of worship, since the reward for worshipping at these three localities is multiplied.
As for someone undertaking a journey without such an intention, then the prohibition in the hadîth will not be applicable to him.
The legitimate means taken to accomplish something have the same legal ruling as the ends for which they are undertaken. Actions are according to intentions. Therefore, whoever travels to carry out a legitimate act of worship that cannot be accomplished without traveling – like traveling to seek knowledge or to uphold kinship ties or to defend Islam or to visit a brother in faith – then he is doing something good and his journey is a journey of obedience.
You mention that your intention for taking this journey is merely to go to a suitable environment to stay in for your i`tikâf. You are not intending for the journey to be an act of devotion in and of itself. You are not going to that mosque because you believe that there is some special significance for worshipping there as opposed to any other locality. You are not – so to speak – making a pilgrimage to that mosque.
However, if you were to believe that journeying to that particular mosque holds some particular virtue or that the mosque itself has some particular religious significance, then it would be forbidden for you to do so.
And Allah knows best.
Source: Islam Today