Using the Apache module mod_auth_form, when a user tries to access a URL and is 'interrupted' by the form based login, how do I pass on the original URL to the html form or to the AuthFormLoginSuccessLocation
directive, so I can redirect the client – upon successful authentication – to the URL where they wanted to go to.
I can add an action="/index.html"
parameter to the form and redirect the user accordingly, but users will reach the login page from several URLs.
I didn't find any information on dynamically setting the value of AuthFormLoginSuccessLocation
. Is there a way to do this with Apache 2.4?
Best Answer
I am redirecting the user to the login page by specifying an error document for status code 401:
ErrorDocument 401 /my/login/page.html
. The login page will pop up whenever a user tries to access a protected resource (unless you use session and he's already authorized). After successfully logging in, the user is redirected back to the target URL by the apache. Therefore, I don't useAuthFormLoginSuccessLocation
directive.A more complete example can be found here (I am not the author).