on the login page, use the following code for the action attribute of the form tag:
action="<?php echo (htmlentities($_SERVER["PHP_SELF"]));?><?php echo(isset($_SERVER['QUERY_STRING'])?"?".str_replace("<","%3C",str_replace(">","%3E",str_replace('"',"%22", $_SERVER['QUERY_STRING']))):""); ?>"
also make sure that in the Security Assist Authenticate user Server behavior the "Go to previous URL (if it exists)" Option is checked.