The 46th prohibition is that we are forever forbidden from living in the land of Egypt. [The purpose of this prohibition is] so that we should not learn from their heresy and not come to imitate their behavior, which the Torah considers wicked.
The source of this prohibition is G‑d's statement1 (exalted be He), "[The king must not accumulate many horses, so as not to bring the people back to Egypt to get more horses, and G‑d told you] you must never again return on that path."
This prohibition is repeated three times in the Torah, as our Sages said,2 "The Torah repeats the prohibition against returning to Egypt three times; on three occasions they returned; and three times they were punished." Of the three times mentioned in the Torah, the first is the verse mentioned above. The second is G‑d's statement,3 "[G‑d will bring you back to Egypt in ships,] along the way that I told you not to ever see again." And the third is G‑d's statement,4 "You are seeing the Egyptians today, but you shall not see them again." Although the plain meaning of Scripture is that it is notification,5 the Oral Tradition tells us that it is actually a prohibition.
It is explained in the end of tractate Sukkah6 that Alexandria is included in the area in which it is forbidden to settle. From the Sea of Alexandria one measures 400 parsah in length and 400 parsah in width, and that area constitutes the "land of Egypt" in which it is forbidden to settle.
However, one may go there in order to do business or to pass through to another land. The Jerusalem Talmud7 says clearly, "You may not return there to live, but may return there to do business and trade or to conquer [another8] land."