うきよ was originally 憂き世 ("this melancholic/miserable world") but reanalyzed as 浮き世 ("this transient/fleeting world") around the Edo period. It was associated with sadness and ethical corruption at first, but later it came to mean "secular part of our world" or simply "this modern world." It also gained associations with mass culture and eroticism. (I did not know 浮き世 could mean "red-light district" in isolation. I believe this usage is exceptional.)
In present Japan, 浮き世 is justalmost an obsolete word, and we almost neverseldom see it outside a few words and idioms including 浮世絵 and 浮き世離れ. Most people understand it has something to do with the "pop culture" of the Edo period, though. The sex industry and pornography was certainly a part of the 浮世 culture, but it's not limited to that.