The area where the village of Casalvieri is located is one of the strategic areas in the Comino Valley, as it controls the narrow passage along the Melfa river that leads from the same valley to the middle valley of the Liri with an outlet in Roccasecca. In addition to Casalvieri center, the municipality has two hamlets: Roselli and Purgatorio, and about ninety small fractions or hamlets. The name comes from the denomination of the medieval settlement: Casa Silverii or Casa Ulivieri.

The Volsci were the first pre-Italian population to have control of the Comino Valley, although their rule lasted little time because they were annihilated by the Samnites, who, in their slow expansion to more fertile lands, entered into collision with Roman interests, causing the 1st Samnite War in 354 BC.

It is now historically proven that the beginning of the great Roman expansion towards the south coincided with the victory over the Samnite confederation in the 3rd Samnite War (which according to Livy began in 298 BC).

The name Casalvieri appears for the first time in a document from the year 1017, dated May 5, the day when brothers Pandolfo IV and Pandolfo II ceded the territory of the city of S. Urbano to the Montecassino abbey, ruled by their brother, the abbot Adenolfo.

In this document, the name Casa Selberi is first mentioned, from which Casalvieri, the current name of the town, will derive. The town will begin to form as an urban aggregation around the Selberi Castle, as confirmed by a subsequent document from 1064, during the phase of fortification.

Few interesting traces of the ancient medieval city remain, such as the city walls and two towers positioned at the north and west corners. In 1076, Casalvieri was given to the Abbey of Montecassino, which was already present in the area with two small monasteries, located today on the border between Casalvieri and Casalattico: Sant’Angelo Pescomascolino and San Nazario, in an area dense with Benedictine religious settlements. Sant’Angelo belonged to a priest of Casa Selveri named Pietro, who in 1032 donated it to Montecassino.

The strategic importance of the territory led to the construction of a castle in the 11th century, which along with Schiavi (Fontechiari) and Casale (Casalattico) was donated by Frederick II to Pope Innocent III in 1215. In the 14th century, it became part of the County of Arpino and then again a possession of the Pope in 1461, before finally being passed on to the King of Naples in 1472. From then on, its history followed that of the Duchy of Sora, administered by the Boncompagni Princes from 1580 to 1796.

In the 18th century, the city experienced interesting urban and demographic growth, leading to the construction of churches and noble palaces, the development of rural settlements (casali), and the restoration of mills and the river Melfa bridge.

Additionally, the historical events related to the Bourbon period and the post-unification era, during which Casalvieri and the Valley were part of the Terra di Lavoro (Caserta Province), are significant. These phases marked the lives of the local populations, particularly due to the persistence of poverty and the rise of banditry.