Other safety stuff because it's the most important bit:
Regarding hiding behind trees - there was a spectator fatality earlier this year and one of the rumours was that they were standing behind some trees which were just flattened by the car that came off. Don't assume standing behind something will save you.
Make sure you have a route
planned for running away. If you get yourself in the middle of a load of stuff (a bush on one side, a big hole on the other and a tree on another) you're going to get stuck or fall over if a car comes off at you. Actually carefully walk the route you're planning to escape via because there can be big holes in the ground to fall in (often full of water) or bits of tree root for you to trip over that aren't visible.
Don't fire off your shots and then stare at the back of the screen until the car is well past you. Loads of people have their head straight into the back of the camera. There's a video knocking about on YouTube of someone doing this and as soon as they look away the car veers towards them and bounces off the barrier they're leaning against just in front of them.
Wear some proper boots with ankle support.
Photographically:
It's dark in the trees so it's best to try and find an open area or at least a partially open area.
You need to be there very early to have chance to walk into the stage and have a look, then get back to somewhere good. You don't want to get caught in a dangerous or photographically-unsuitable place when the stage goes live. Having maps of the stage will be helpful and if you think you might do the event, or another local event that may use the same stages, again then do a bit of recce work - I take shots on my phone as I walk past and note where they are.
Watch for branches and bits of grass getting in your shots. You can miss them while shooting or looking on the camera's screen because they'll be out of focus and thus less noticeable but they'll be visible once you get them on a PC and they'll either take a lot of work to photoshop out or it just won't be practical to remove them at all.
Panning is probably best done on the first run of a stage as the stage will cut up which makes it bumpier the second time they go through (assuming the stages get used more than once).
As other people have said the cars will throw up bits of the road surface which you can use to communicate that the cars are moving, even while using a high shutter speed. If it's been dry you'll get
big dust trails but if it's damp or the ground is slightly frosted you'll only get
rocks and bits of mud that don't kick up as much. Though they do kick up enough to hit you.
Don't just take "car shots". Try and get some of the car in the environment, though obviously this requires that you find an interesting bit of landscape.