Yes, Non-Muslims may not enter or travel through Mecca and attempting to enter Mecca as a non-Muslim can result in penalties such as a fine or deportation from Saudi Arabia. However, in Medina, both Muslims and Non-Muslims are allowed. The exception is non-Muslims entering the Nabawi Square, where the Al-Masjid Al-Nabawi is located. non-Muslims are not allowed in Mecca because it is a holy sanctuary. One has to qualify certain requirements to be there and be a believer. Understand it like this: civilians are allowed in cantonment areas or high security areas. You need a certain permit to be there. It’s the same with Mecca. In this case the permit is being a Muslim. Also please note that Mecca as a city has no significance. The only significance is the presence of Kaaba.
also read Jumma Prayer: Why Muslims select Friday to pay special Namaaz
Here it is to be noted that Mecca and Madinah are cities of great importance in Islamic tradition - centers of pilgrimage and prayer, sacred places where Muslims are free from the distractions of daily life. Restricting access to these holy cities is intended to provide a place of peace and refuge for Muslim believers and preserve the sanctity of the holy cities. At this time, millions of Muslims visit the cities each year, and additional tourist traffic would simply add to the congestion and detract from the spirituality of the pilgrimage visit. Mecca was under the control of the Ottoman Empire from 1229 to 1923. The quote below is from a text available from 1564 in which it states that in those times only people who did not believe in one God were forbidden entry into Mecca. ‘No Muslims and believers in the unity of God should be hindered in any way if he wishes to visit the Holy Cities and circumambulate the luminous Ka’ba [in Mecca].’42 42. M.D., vol. 6, f. 17, firman no. 39, 1564-5, quoted by Faroqhi, op. cit. 147 (Ottoman imperial firman).
However, it is worth mention here that the Quran says: “Oh you who believe! Truly the idolaters are unclean; so let them not, after this year, approach the Sacred Mosque….” (Quran – 9:28) Mosques or holy places in other religions as well as places reserved for meditation usually have basic requirements for entry - cleanliness and purity. Prayer is a form of meditation and meditation requires cleanliness. This basic principle drives the restriction to not allow someone 'not clean' into a Mosque - be it a Muslim or a non Muslim. Although it is said that even Muslims are prohibited to enter the Mosque if they are not clean, but no one can keep a check on this. It is believed that every Muslim will follow cleanliness guidelines as per Islam which mentions a specific way to take bath and perform ablution to touch the holy book of Quran or perform prayers. It is obviously assumed that people from other religions being unaware of these rules are not purified in that sense and hence denied entry to Mecca.
also read Muhapatti : Why Jain Monks wear cloth t cover their mouth? know detail here