diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py
index d8093d0aac864b6ea6f4aef0877c739f8d32e21a..53fd48aa21ce239c6c8ed781f65a17ae6de9be6b 100644
--- a/flask_simpleldap/__init__.py
+++ b/flask_simpleldap/__init__.py
@@ -294,8 +294,12 @@ class LDAP(object):
         @wraps(func)
         def wrapped(*args, **kwargs):
             if g.user is None:
+                next_path=request.full_path or request.path
+                if next_path == '/?':
+                    return redirect(
+                        url_for(current_app.config['LDAP_LOGIN_VIEW']))
                 return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'],
-                                        next=request.full_path or request.path))
+                                        next=next_path))
             return func(*args, **kwargs)
 
         return wrapped