By Greg Beacham

The Associated Press

Next up

San Francisco at Washington

When: 10 a.m. Sunday

TV: Fox

LOS ANGELES — The Los Angeles Rams ran the ball on their first seven consecutive plays, marching straight through San Francisco’s defense for 65 yards and a touchdown.

“That definitely hits you on a personal level,” 49ers defensive tackle and former Oregon star DeForest Buckner said. “I’m pretty sure a lot of guys took it personally.”

The Niners’ defense vowed to spend the rest of a memorable Sunday making up for that embarrassment. And with a fourth-down stop on the goal line several minutes later, San Francisco completely changed the direction of this NFC West rivalry.

Jimmy Garoppolo passed for 243 yards and ran for a touchdown, and San Francisco remained unbeaten with a dominant defensive performance in a 20-7 victory over the struggling Rams.

George Kittle had eight catches for 103 yards for the Niners (5-0), but their tenacious defense did most of the work. San Francisco held Los Angeles’ once-unstoppable offense to 157 yards in coach Kyle Shanahan’s first victory over Rams coach Sean McVay in a game in which both California rivals were playing their starters.

“L.A. has gotten after us a lot the last couple of years, so it was a game for us to come out here and just show that we are back and for real,” Niners defensive lineman Solomon Thomas said.

These rivals are going in opposite directions after this one-sided showdown at the Coliseum. San Francisco stayed alongside New England as the NFL’s only unbeaten teams, while the Rams (3-3) are on their first three-game losing streak of McVay’s 21⁄2-year tenure.

After enduring two miserable seasons while the Rams reached Super Bowl heights, the Niners were eager to reassert themselves in this classic NFL rivalry.

San Francisco won a defense-dominated game by thoroughly throttling the defending NFC champions’ once-impressive passing game.

Jared Goff went 13 of 24 for a career-low 78 yards while failing to get comfortable behind a porous offensive line, and the Rams did not manage a completion longer than 12 yards while going 0 for 9 on third down and 0 for 4 on fourth down.

“We were running the ball so well early, and we were trying to stick with that,” Goff said. “We just never really got in a rhythm. Their defense was able to settle in, and that’s part of it.”

The game was still up for grabs when the Rams reached the San Francisco 1-yard line on third down shortly before halftime, but the Niners smothered two straight running plays up the middle.

“It sparks everybody,” Garoppolo said. “Coaches, players, everybody is hollering on the sideline.”

Tevin Coleman rushed for an early touchdown for San Francisco, while Garoppolo was mostly effective despite two turnovers.

The Niners did not score a touchdown in the final 27 minutes, but they are off to their fourth 5-0 start in franchise history, and their first since 1990.

With Todd Gurley sitting out to rest his bruised thigh, Los Angeles could not move the ball in its least productive performance of McVay’s tenure.

Robert Woods rushed for a touchdown on the opening drive for the Rams, who then managed just 48 net yards on their next seven drives combined.

“We came out and started fast, but it comes back to consistency,” Woods said. “We look like a good offense sometimes, (and then) we look like a bad offense. We’re just not being consistent.”

The Niners’ offense was not significantly better during a first half in which both teams turned the ball over at the opponents’ 1, but San Francisco capitalized on Rams rookie Darrell Henderson’s fumble on the opening snap of the second half for a short go-ahead TD drive capped by Garoppolo’s sneak.

San Francisco then took control, moving the ball deliberately and thoroughly shutting down the Rams. Garoppolo’s fumble was returned to the San Francisco 36 with 8:40 to play, but the Rams promptly turned it over on downs.

“After that, I had a feeling that if we just don’t turn it over, we’ll win this game,” Shanahan said. “I haven’t had that feeling very much in my career, and the defense definitely gave it to me the whole game.”