In the United States, prostitution has usually been illegal everywhere, with very few exceptions. The bawdy houses you see in movies only existed in mining boom towns and places where enforcement was lax, such as places with large amounts of foreign immigrants. As an example of the laws which were more or less similar throughout the country, here is the relevant act from the Consolidated Laws of Kansas, 1879:
(788) § 50. Sec. 49. The city council shall have power to enact
ordinances to restrain, prohibit and suppress tippling shops, billiard
tables, — bowling alleys, houses of prostitution and other disorderly
houses and practices, games and gambling houses, desecrations of the
Sabbath day, commonly called Sunday, and all kinds of public
indecencies. No license shall ever be granted for any house of
prostitution, or for any gambling house, gambling device, game of
chance, or any disorderly house or practice; and no city officer shall
accept or receive any hush money, or any money or valuable thing, from
any person or persons engaged in any such business or practice, nor
grant any immunity or protection against a rigid enforcement of the
laws and ordinances enacted to restrain, prohibit and suppress any
such business or practice.
As you can see from the law, it was a common practice to bribe officials to overlook the laws.