Let's highlight the main stages in the formation of the flag:

Flag from 1831 to 1832. During the struggle for Bosnian autonomy from September 1831 to June 1832, a new Bosnian flag was adopted. At the beginning of 1832, Bosnia and Herzegovina was briefly liberated from Ottoman rule and declared independent. The flag used during this period was green with a yellow moon and a yellow five-pointed star in the middle of the moon on the right side of it.
Flag from 1878 to 1908. After the Austro-Hungarian conquest of Bosnia and Herzegovina in 1878, a new flag was made for Bosnia and Herzegovina. All the flags of the Austro-Hungarian monarchy had a standardized look and were divided horizontally into two equal parts with different colors. For Bosnia and Herzegovina, red was chosen for the top and yellow for the bottom. In the middle of the flag is the then coat of arms of Bosnia and Herzegovina. The flag was adopted in late 1878.
Flag from 1908 to 1918. After the annexation of Bosnia and Herzegovina by Austria-Hungary in 1908, a new flag was used. It was almost the same as the previous flag, except for the coat of arms of Bosnia and Herzegovina, which was removed from the flag. Thus, two colors remained: red at the top and yellow at the bottom.
Flag from 1946 to 1992. The flag of the People's Socialist Republic of Bosnia and Herzegovina was solid red with the flag of Yugoslavia, outlined in yellow, in the upper left corner. Prior to the adoption of this flag, the flag of Bosnia and Herzegovina was a red flag with a star in the middle decorated with gold. The flag was adopted on December 31, 1946.
Flag from 1992 to 1998. On May 4, 1992, the flag of the Republic of Bosnia and Herzegovina was adopted. The flag of the Kingdom of Bosnia was based on the coat of arms of the Bosnian Kotromanic dynasty, King Tvrtko I and his successors. The flag of medieval Bosnia was white with the coat of arms of the Kotromanic dynasty in the middle, which consisted of a blue shield with six golden lilies (French fleur de lys - a sign of the saints or blessed in heraldry) placed around a white bend (English bend, French bande - in heraldry, a diagonal band that crosses the shield). The ratio of the flag's width to length was one to two. It was officially presented for the first time on May 22, 1992, in front of the UN building in New York.
Modern flag. The flag was officially approved on February 4, 1998. It was chosen among three options presented to the parliament. All of them contained the color blue, which symbolizes the United Nations. The white stars represent Europe. The yellow triangle represents the three main ethnic groups living in the country: Muslims, Croats, and Serbs.