I'm using the following code to create a login link that will redirect the user to the previous page:
<a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>
The problem is that get_permalink() as described here: http://codex.wordpress.org/Template_Tags/get_permalink will return the URL of the last post in The Loop, not the permalink for the current page when used on archive pages or index pages. How can I get around this? As it is currently redirecting my users to incorrect pages.