diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py
index 82ae17fcd2326e51a2617ac8a7ca485cf5274ef6..b8af16db9622a53990419397ba4be558a20344b9 100644
--- a/flask_simpleldap/__init__.py
+++ b/flask_simpleldap/__init__.py
@@ -302,7 +302,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
@@ -328,7 +328,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)