Damon Landor is a Rastafarian. His faith requires him to let his hair grow long. When he started a five-month prison term for drug possession in Louisiana, his dreadlocks fell nearly to his knees.

Mr. Landor was wary of the state’s prison system, and he kept a copy of a 2017 judicial decision with him. That ruling, from a unanimous three-judge panel of the U.S. Court of Appeals for the Fifth Circuit, said that Rastafarian inmates in Louisiana must be allowed to keep their dreadlocks under a 2000 federal law protecting prisoners’ religious freedom.

The first four months of Mr. Landor’s incarceration were uneventful. Then he was transferred to the Raymond Laborde Correctional Center in Cottonport, La. He presented a copy of the 2017 decision to a guard, who threw it in the trash.

After consulting the warden, two guards handcuffed Mr. Landor to a chair, held him down and shaved his head to the scalp.

“When I was strapped down and shaved, it felt like I was raped,” Mr. Landor said. “And the guards, they just didn’t care. They will treat you any kind of way. They knew better than to cut my hair, but they did it anyway.”

He sued the warden and the guards under the 2000 law, the Religious Land Use and Institutionalized Persons Act. When the case reached the Fifth Circuit, the same court that had ruled that the law protected Rastafarian prisoners’ dreadlocks, a different three-judge panel said that “we emphatically condemn the treatment that Landor endured.”