Redding will receive $6 million over those two years, a league source told NFL Network insider Jason La Canfora.
"Cory is a guy who plays like a Raven," general manager Ozzie Newsome said. "He hustles, he plays with intelligence, and he can play multiple positions like many of our defensive players. He's been a starter at both inside tackle and defensive end. And I am sure our coaches will use him in both positions."
Redding was an unrestricted free agent. His best season came in 2006, when he had 16 starts and finished with eight sacks and 70 tackles.
Harbaugh expects to use Redding in a variety of ways.
"He can rush from the inside, rush from the outside, he can probably even play the rush position, which is where we put Dwan Edwards at times on first down last year," Harbaugh said. "I think he's a similar player to Dwan. Obviously, Dwan had a great year for us. We're hoping he fills that spot for us."
Redding was selected by the Lions in the third round of the 2003 draft after playing his college ball at Texas.
The Associated Press contributed to this report.