Don’t mess with Mike Bloomberg when he’s hitting a golf ball.

The billionaire business mogul and former New York City mayor hates it when he plays on golf courses where vehicular traffic cuts through the greenery and interrupts the flow — and safety — of the players.

A new biography out next month — “The Many Lives of Michael Bloomberg” by Eleanor Randolph — discusses how Bloomberg prodded traffic officials to give golfers the right of way like pedestrians by installing traffic signals on the courses he played on.

“He wanted his favorite golf courses to flow from green to green with no interruption from the outside — like a road cutting between fairways,” Randolph said.

During his mayoralty, Bloomberg visited La Tourette Golf Course on Staten Island and complained that golfers had to stop for traffic to get from one hole to the next as Richmond Hill Road splits the golf course in half.

“He wanted a signal, to give priority to golfers, even though traffic engineers resisted,” the book says.

But Bloomberg got his way.

“In the end, six months after he left office, the city’s transportation department finally agreed to put up a flashing yellow light that turned red when golfers were trying to get across,” Randolph said.

Bloomberg in 2016 also met with Southampton Town Hall officials on Long Island to try to persuade them to close a road through the Shinnecock Hills Golf Club, which happens to be near his $20 million, 35-acre estate in Ballyshear in the Hamptons.

Tuckahoe Road runs through a section of the Shinnecock course.

“The proposed rerouting of this road infuriated neighbors who enjoyed the scenic shortcut through the golf course, and when word got out, they bristled at Bloomberg’s interference,” the book said.

But Bloomberg was able to secure a compromise two years later with the town and golf club.

“The road would be closed only when the US Open was being played at Shinnecock, but would reopen after that busy week,” according to the book.