INGLEWOOD, Calif. (AP)For one half, the Los Angeles Rams looked as if they had finally figured out the San Francisco 49ers, putting together two sustained touchdown drives.

In the second half, the offense fell into the same rut that has defined what is now an eight-game losing streak in the regular season to their Bay Area rivals.

The Rams were shut out in the final 30 minutes of their 31-14 loss to the 49ers on Sunday, managing just 58 yards on 25 plays without ever driving into opposition territory.

”First half was ours. Just got to figure out how to do it again, and then string a game together,” Los Angeles center Brian Allen said.

Los Angeles (3-4) actually took a 14-10 lead into halftime on a 1-yard touchdown run by Matthew Stafford and a 16-yard touchdown pass from Stafford to Cooper Kupp.

But those possessions, which lasted 17 and nine plays respectively, included signs of the issues that would sink the Rams in the second half.

While undrafted free agent Ronnie Rivers got the start at running back after being activated off the practice squad on Saturday, the rushing attack effectively consisted of short passes and screens to minimize chances that a makeshift offensive line would buckle.

The approach worked as the Rams got down to Niners 10 on their second drive. Once there, it took them eight plays to finally get into the end zone, benefitting from penalties for defensive holding and pass interference before Stafford finally scampered in at the right pylon on the home team’s sideline.

”I’ve played this game long enough to know you’ve got to do it every single drive,” said Stafford, who threw for 150 of his 187 yards in the first half. ”Just ’cause you have a good drive here and there doesn’t mean that the game’s gonna go that way. It’s a four-quarter football game for a reason.”

San Francisco (4-4) switched things up in the second half, taking away those comfortable throws while daring Los Angeles to run the ball. The Rams turned 11 carries into 41 yards, a significant improvement after averaging 1.5 yards per attempt in the first half, but not nearly enough while chasing the game.

The Rams were 3 for 7 on third down in the second half. Stafford was sacked twice. Kupp touched the ball three times for 19 yards.

And in the few instances when there were chances to make plays, the Rams couldn’t execute. Tight end Tyler Higbee was wide open with room to run on a third-and-3 trailing 24-14 early in the fourth quarter, but he dropped Stafford’s throw.

”Everybody has their hand in. Football’s an imperfect game,” Stafford said. ”I wish I would have that thing right out in front on his chest and let him keep running with it, so I appreciate the kind of guy that he is and the football character that he has. I hope he feels like I have the same. Wish I could have been better for him.”

Midseason swoons are nothing new for Los Angeles, which lost all three games in November last season before getting back on track en route to winning the Super Bowl. Those Rams had already built up a margin for error that this year’s team lacks, and coach Sean McVay cannot rely solely on positive memories to turn things around.

”This is one of those deals that you got to be able to look yourself in the mirror, get up and respond the right way,” McVay said.

More AP NFL coverage: https://apnews.com/hub/nfl and https://twitter.com/AP-NFL