Everything was aligned Thursday night for the Yankees to deal with cold sweats and nightmares.

CC Sabathia against the Rays was a matchup that didn’t favor the Yankees, and it was awful with the ace working at Tropicana Field.

With David Price on the mound for the hosts, runs figured to be at a premium.

Nevertheless, the Yankees avoided the sweats and the nightmares as Sabathia took advantage of an extra-base orgy that included three homers — two off Price — and a triple play to help the Yankees rip the Rays 10-2 in front of 28,085.

“I’ve struggled here, especially against Price,’’ said Sabathia, who was 1-7 with a hefty 4.75 ERA in 11 starts at the Trop as a Yankee. In the previous nine games started by Price and Sabathia, the Rays had won eight with Price going 6-1. “These guys came in here swinging.’’

The Yankees’ fifth straight victory was more than flexing muscles that led to back-to-back homers by Alfonso Soriano (3-for-5) and Brian McCann in the fifth off Price and Yangervis Solarte’s two-run shot off Grant Balfour in the ninth.

It was highlighted by Solarte starting a 5-4-3 triple play in the second inning with the Yankees leading 4-0 and the Rays having runners on first and second.

“I was thinking if they hit the ball close to [third] I’d get the ball go to the base, throw to second base,’’ Solarte said of Sean Rodriguez’s grounder that was almost at the bag.

Solarte tagged third, fired to Brian Roberts at second and then watched Scott Sizemore, making his initial start at first in his life, scoop Roberts’ throw out of the dirt for triple play.

“He made it look easy,’’ Roberts said of Sizemore’s scoop that had Sabathia raise his arms in celebration.

Sabathia was also on the mound last April 12 when the Yankees turned a bizarre triple play against the Orioles at Yankee Stadium and hurling on April 22, 2010 against Oakland when the Yankees got three outs on one pitch.

“I’ve never been part of one of those,’’ said Roberts, who went 3-for-5 with two RBIs after missing the previous three games with a back issue. “Apparently CC does it all the time.’’

“It was lucky, just unbelievable. I was just trying to make a pitch to get a double play,’’ said Sabathia, who allowed two runs (one earned) and seven hits in seven innings and is 2-2. “Solarte made a great play and Sizemore made an even better play with the pick.’’

By the time Solarte homered, the outcome wasn’t in doubt. But he finished 3-for-5 and is batting .373 (19-for-51) in his first 15 big league games.

“It’s been incredible for me and I don’t want to wake up,’’ said the 26-year-old switch-hitter, who spent eight years in the minors before making his major league debut with the Yankees this season. “I want to work hard and continue what I’m doing.’’

The one down aspect of the win was Carlos Beltran running into a fence in foul territory down the right field line in the third inning. Beltran hit the fence at full-speed chasing a foul ball and went over it. He stayed in the game, but Beltran was examined by a doctor afterward and wasn’t sure if he would be able to play Friday night.