The most important rules are to always wear a helmet, keep your bike in perfect mechanical condition, stick to trails you have the skills to ride, and to always ride within your limits. If you can do these things, there's an excellent chance your off-road rides will be safe and fun.
Here are some other tips that help a lot:
1. Make sure your tires aren't over inflated. The recommended pressures are written on the sides of the tires. Most off-road rubber should be pumped to 35 to 40 psi. If you're riding with 60, as many newbies start out, you'll get bounced all over the trail and lose control. At softer pressures, tires have much more give providing more contact with the ground and significantly more control and comfort.
2. On steep downhills, shift your weight rearward by sliding well back on the seat, even off the seat and over the rear wheel, if necessary. This will prevent going over the handlebars.
3. Go easy on the brakes. Slam on the grippers too hard and you can lock the wheels and start skidding, a dangerous no-control situation. Also, if you hit the front brake too hard, you can launch yourself over the handlebars. Spectacular, yes; but darn painful, too. So avoid it.
4. Don't follow ride partners too closely because you won't be able to see the hazards until it's too late.
5. To learn technical skills such as bunny hopping (jumping over things), riding over slippery roots, cruising through mud and sand, etc. practice in a controlled environment with a friend, or even better, friends, spotting. They can offer tips, see what you're doing right and wrong and generally help keep you safe, and you can do the same for them.