SANTA CLARA >> The Los Angeles Rams have gone six quarters and 22 years without a regular-season touchdown. Some things are worth waiting for, but it’s hard to put Monday’s game in that category.

In what could have been a celebration, a cathartic end to the saga of the relocated Rams, they flopped against the one division opponent they should beat handily. Dreadful on offense, the Rams continually wasted opportunities and suffered a season-opening 28-0 loss to San Francisco at Levi’s Stadium.

The Rams were shut out for the first time since Dec. 24, 2011, a 27-0 loss at Pittsburgh.

“It’s embarrassing for us to go out there and not put any points on the board, but it’s a long season,” Rams running back Todd Gurley said. “We’re going to bounce back and get (angry) and get ready for Sunday.”

In their first regular-season game representing Los Angeles since Dec. 24, 1994, the Rams trailed 14-0 midway through the second quarter. San Francisco, certainly no offensive juggernaut itself, added a big touchdown early in the fourth quarter when Vance McDonald caught an 8-yard pass from Blaine Gabbert.

The Rams didn’t handle adversity well. Late in the fourth quarter, star defensive tackle Aaron Donald was ejected after he shoved the helmet off the head of 49ers receiver Quinton Patton and made contact with a game official during the ensuing scrum. The 49ers made it 28-0 a few plays later.

Donald said he became upset when he saw teammate Alec Ogletree surrounded by 49ers.

“I just saw some things happen and tried to run over there and break it up,” Donald said, “and I got a little too physical. That was just dumb on my part.”

The Rams totaled 186 yards of offense and 102 penalty yards and totaled 10 first downs. They went 3 for 15 on third downs. Quarterback Case Keenum, who beat out heralded rookie Jared Goff for the starting job during the preseason, made poor decisions with the ball throughout the game.

So the Los Angeles Rams still haven’t won, or scored, in a while. In the second quarter of that 1994 season-ending loss to Washington, Chris Miller threw a 36-yard touchdown pass to Jermaine Ross. That will hold up at least until the Rams play Seattle in their home opener Sunday at the Coliseum.

The Rams’ offense, awful last season, somehow got worse against a 49ers defense that isn’t exactly scary. The Rams’ interior run blocking was nonexistent and Keenum struggled.

Keenum completed 17 of 35 attempts for 130 yards and had two interceptions.

“I’m not happy,” Keenum said. “This team deserves better play from its quarterback, and I intend on doing that. This is not going to define me. … It’s a long season, and this is not us. Offensively, it’s not us.”

The star of the night for the Rams, so to speak, was Johnny Hekker, who punted 10 times for a total of 431 yards. He “outgained” the Rams’ offense by 245 yards.

At one point, the Rams failed on 10 consecutive third-down attempts, and had four consecutive three-and-out possessions. Other than a couple strong mid-range completions between Keenum and receiver Kenny Britt, the Rams offered almost nothing on offense.

Star running back Todd Gurley, who should have feasted on an ineffective and injury-riddled 49ers defensive front, broke only a couple outside runs and finished with 47 yards on 17 carries.

The Rams’ other big-play threat, receiver Tavon Austin, never got going. Keenum targeted Austin on 12 passes, but they connected for only four catches for 13 yards.

The Rams’ offense, too often, turned into stuffed inside runs and short outside passes. Any thought that Keenum would be an effective game manager who could lead the Rams down the field on long, patient drives, ended early. He looked rattled under pressure and too often forced passes into coverage.

At one point in the fourth quarter, the Rams had backup quarterback Sean Mannion warming up on the sideline. Goff, the first pick of this year’s draft, stood on the sideline as one of the Rams’ seven inactive players.

In that sense, perhaps Goff won the night, although after the game, Coach Jeff Fisher said Keenum’s play wouldn’t spark a change at quarterback.

The Rams, trailing 14-0 in the third quarter, had a chance to get back in the game with the ball at the San Francisco 26. Instead, Mannion made a terrible read and easily was intercepted by linebacker Ray-Ray Armstrong.

Coming into the game, conventional wisdom was that the Rams — with Gurley — would be able to run the ball against an injury-riddled and ineffective 49ers defensive front.

It didn’t happen. The Rams actually came out throwing on their first drive, with six pass plays and only two run plays, and actually moved the ball to the San Francisco 46 before being forced to punt. And that nine-play drive held up as the most efficient of the night for the Rams.

The Rams’ defense shouldn’t be let off the hook either, at least from a scheme perspective.

After the Rams released starting linebacker Akeem Ayers at the end of the preseason, and put a big dent in their depth at that position, Coach Jeff Fisher said the unit would be fine, and that the Rams would run a nickel package against most teams, most times, anyway.

That’s how the Rams came out Monday, with Alec Ogletree and Mark Barron at linebacker, and Trumaine Johnson, Coty Sensabaugh and Lamarcus Joyner at cornerback. San Francisco coach Chip Kelly, who prefers a run-first offense anyway, seemed well-prepared to attack the Rams.

Early in the game, the 49ers’ offensive line surprisingly got the better of the Rams’ talented defensive front. Gabbert, facing only two linebackers, found running room up the middle, as did running back Carlos Hyde.

That allowed the 49ers to have much-needed offensive balance. Gabbert completed 22 of 35 attempts for 170 yards and also ran for 43 yards, while Hyde ran for 88 yards and two touchdowns.