They retook the lead before half-time as Emmanuel Fernandez powered a header in from Rothwell's free-kick for a goal on his debut.
The hosts continued to push forward after the break, but it took a contentious penalty for Rangers to find their third.
VAR Greg Aitken advised referee Dan McFarlane to go to the pitchside monitor after Alloa's Cammy O'Donnell handled in the box in a 50-50 with Oscar Cortes.
McFarlane awarded the spot-kick and substitute James Tavernier duly converted to put Rangers two goals to the good.
Alloa continued to push, though, and veteran striker Conor Sammon caused plenty of issues for the Rangers backline having been introduced off the bench.
And they set up a nervy ending at Ibrox when Scott Taggart tapped home after Danny Devine's header came out off the crossbar.
Andy Graham's side were unable to find another equaliser, though, and Findlay Curtis sealed Rangers' spot in the last eight with a precise right-footed finish late on.