diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py
index 12f28b91a8d2c0459313f895325abcc719824e3c..73ab24c1644300c0573f6687197fc94930af0152 100644
--- a/flask_simpleldap/__init__.py
+++ b/flask_simpleldap/__init__.py
@@ -296,8 +296,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