Unlike the vastus intermedius, vastus medialis, and vastus lateralis of the quadriceps muscle group, which act only as knee extensors (straightening the leg at the knee), or the iliopsoas, which acts only as a hip flexor, the rectus femoris (RF) is both, attaching at the iliac spine of the hip bone, as well as the patellar tendon with the rest of the quads.
This means that the RF can get tightened up by all of the usual quadriceps exercises - squats, lunges, jumps - as well as through driving a car or just sitting at a desk.
A common adage in strength training is that exercising with tight hip flexors is like driving with the parking brake on. And while there are several good hip flexor and quadriceps stretches, it takes action at both the knee and the hip to fully stretch the rectus femoris.
The most effective stretch for the RF is what Kelly Starrett, the CrossFit Movement and Mobility coach, has called the "couch stretch", due to the effectiveness of performing it braced against a sofa while relaxing in the evening.
To perform the stretch, place one foot on the seat of the couch (or up against the arm of the couch for a more advanced stretch) with the shin as close to vertical as possible. Plant the other foot on the floor, with approximately a 90-degree angle at the knee. Gently press your body into an upright position, using your hands on your resting thigh if needed. Once you've reached a good stretch, hold for a minimum of 1 minute, and as much as 3 minutes, and switch sides.
The couch stretch may be uncomfortable when starting out - many people have tight enough hip flexors, including the RF, that it may take several stretching sessions to work into a full upright position. Gradually work on it, and you'll find that your mobility, your posture, and your strength will improve dramatically!