Redirect to requested url after signup

I have an application where I want users to be redirected back to the original requested url after they sign up. How can I accomplish this?

IMPORTANT NOTE: Redirection works when a user is logging in (the user is being redirected to the requested url after they log in). It just doesn’t work when a user signs up.