Actually, some people have the sparkplugs in the exhaust, but the rally cars have those flames shooting out because of the ANTI-LAG system they have.
Basically, the anti-lag is a system programmed in the Engine management injecting an amount of fuel + lighting the sparkplug (plus other timing related adjustments) when the driver is releasing the gas pedal to shift. It is timed to ignite the fuel in the exhaust manifold right before the turbo. Even if the engine is not producing exhaust flow, the turbo is kept spooling by the explosion of the extra fuel in the manifold. The results of the explosion are channelled through the exhaust system creating that wonderfull flame.
This setup is extremely bad for exhaust wheels and turbo housings, but for the elimination of Lag during a Rally, it's well worth it!