Simplified code to get redirected url