The Messenger of Allah ﷺ ruled that whoever commits fornication and is unmarried shall be banished for a year in addition to receiving the prescribed punishment.
حدثنا حجاج قال حدثنا ليث قال حدثني عقيل عن ابن شهاب عن سعيد بن المسيب
عن رسول الله ﷺ أنه قضى فيمن زنى ولم يحصن أن ينفى عاما مع الحد عليه
Its isnad is sahih. It is found in Bukhari, 5/255, no. 2649, Fath, in the Book of Testimonies, chapter on the testimony of the slanderer, the thief, and the fornicator, and in Malik, in the Book of Punishments, chapter gathering what has been said regarding the punishment for fornication, 2/827. But this hadith includes banishment along with the fixed punishment, and most jurists did not adopt it, saying it had been abrogated.