diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py
index abeb4181bfdacbcc10116767a4323ca76b07403d..f288d9aa2a35dc821a3f264b3c78a9c9f06ad557 100644
--- a/flask_simpleldap/__init__.py
+++ b/flask_simpleldap/__init__.py
@@ -304,7 +304,7 @@ class LDAP(object):
         def wrapped(*args, **kwargs):
             if g.user is None:
                 return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'],
-                                        next=request.path))
+                                        next=request.full_path or request.path))
             return func(*args, **kwargs)
 
         return wrapped
@@ -330,7 +330,7 @@ class LDAP(object):
                 if g.user is None:
                     return redirect(
                         url_for(current_app.config['LDAP_LOGIN_VIEW'],
-                                next=request.path))
+                                next=request.full_path or request.path))
                 match = [group for group in groups if group in g.ldap_groups]
                 if not match:
                     abort(401)