Shariat has clearly defined certain places for wearing ehram, these are called miqaat. One may not bypass these designated areas and proceed to Makkah without ehram.
Ordinarily people proceed to Makkah in one of these three ways:
1.First go to Madinah then proceed to Makkah for Hajj:
When these people leave Madinah they will come across Masjid-e-Shajarah at a distance of 6 miles from Madinah. This is a miqaat from where the Hajj ehram should be worn.
2.First go to Makkah for Hajj then proceed to Madinah:
When such persons reach Jeddah they should proceed to Johfah which is a miqaat and wear the ehram of Hajj from there. However they can, before reaching Jeddah (in their hometown or in the plane) wear ehram.
3.First go to Makkah then go to Madinah then return to Makkah for Hajj:
Such people when they enter Makkah for the first time should wear ehram of Umra-e-Mufrada, then they go to Madinah and when they return to Makkah they should wear the ehram of Hajj at Masjid-e-Shajarah. These people are initially required to wear ehram of Umra-e-Mufrada, because once you have entered Makkah wearing the ehram of Umra e Tamatto you cannot leave Makkah till Hajj is complete, while these people would like to go to Madinah before Hajj.