With difficulty. Not an easy effect to pull of well, but this Video CoPilot tutorial might give you some ideas, as well as this article on Forrest Gump. If you can find it, the October '94 edition of American Cinematographer has a feature on Forrest Gump too.
I can be as simple as masking an arm or leg....or torso. In the above shot, the legs are fake, but the torso is a real guy. His legs are simply masked out. That required a "plate" shot of the bare floor, so you have something to show when you erase the legs.
Here's an effect breakdown from Will Vincent's work on our short "Deathbed" a few years back... it shows all of the bits used in the effect... the gore bit was a piece from a headless horseman costume from a catalog scanned, flipped and scaled to fit the shot.