Short answer first: use the search function. I'm not trying to be rude, but this topic has been covered so much, that there are tons of really smart answers. You'll learn more from that search than you will from any one answer here.
Now, some tips: there are no hard and fast rules, as there are so many variables: your guitar, your amp, your mic, etc. (So tell us more about what you're working with).
It's very common for a good "jamming sound" not to sound so good when recorded. Gain/distortion that sounds good in a room sounds good because it's filling the room. If you put your ear right up to the grill cloth (which is about where your mic should be) you'll notice that high gain guitar sounds fizzy. And if it sounds to bassy, there's a good chance your into a heavy, scooped sound.
What I've learned in the past few years, is that less gain and more midrange works for recording. Even if you want a heavy sound. The bass guitar covers the bottom (thus the "more midrange" suggestion) and its common to double track (play it twice and pan 'em left and right) to get a big heavy sound with less distortion.
I've made assumptions on what you're going for, so like I said, tell us more about your setup and the sound you're going for, and we can help you more...