Exclusive

The son of ex-'Real Housewives of Orange County' star Lauri Peterson is getting his wish to be transferred to a new jail, where he and his mom believe he'll be much safer.

A judge approved the move on Friday for Josh Waring. He'll be leaving lockup in the Orange County Jail and heading to the Santa Ana City Jail ... which means he'll no longer be in custody of OC Sheriff's deputies and corrections officers, who he and Lauri believe are trying to get him killed.

Josh will get all the same privileges -- library access, unlimited calls, healthcare, etc. -- he had at the OC jail. He's scheduled to be transferred later Friday.

Play video content TMZ.com

We broke the story ... Josh was ambushed last month at the county jail and brutally attacked by another inmate wielding razors wrapped in towels. That inmate was supposed to be locked in his cell.

Waring suffered deep gashes to his chest and face, and he and his lawyer believe the incident is the latest proof his life was in danger in the OC jail.

Play video content TMZ.com

In fact, Lauri told us the attack came after guards threatened to kill Josh and he'd already suffered multiple other assaults -- 3 by inmates and at least one by a guard.

Waring's lawyer, Joel Garson, believes it could be retaliation against Josh for filing a federal lawsuit against Orange County and its Sheriff's Department for violating his civil rights. He claims jail officials illegally recorded his attorney-client calls. That case is ongoing.

As for the October attack, you'll recall one of the correctional officers claimed Josh stated right afterward he knew the guards didn't set him up ... but Garson denied that and doubled down, saying the guard's claim is a "cover your ass" statement.