You have a cat with a cystitis that suddenly has the urgency to pee. It relieves that urgency by peeing, and after this happens a number of times, the cat learns that it is far more pleasant to pee on the rug where it's not so dusty, or so smelly, or so rough and uncomfortable, etc. So far we may have a medical problem which has turned into a behavioral problem. It may however be a behavioral anomaly that you are first observing with the onset of a medical problem. Let's better define the problem.
Cats have two basic postures for expelling urine from their bodies.
This is where cat raises its tail, backs up to some vertical surface or vertically-oriented object and shoots urine strait or almost strait back. This is most commonly associated with urine marking, a predominantly male behavior primarily driven by testosterone. This is what is known as a learned behavior. In the last few years I have discovered an interesting phenomena. Distinguishing between such factors is essential to accurately diagnosing problems, and this is the key to making appropriate treatment recommendations.