Login redirect after link

I protected a specific page with a login. It is linked on the homepage. now I need to redirect to the linked page instead of the homepage after logging in. My login controller looks like this:

return function($site, $pages, $page) {
  // don't show the login screen to already logged in users
  if($site->user()) go('/');
  // handle the form submission
  if(r::is('post') and get('login')) {
    // fetch the user by username and run the
    // login method with the password
    if($user = $site->user(get('username')) and $user->login(get('password'))) {
      // redirect to the homepage
      // if the login was successful
    } else {
      // make sure the alert is being
      // displayed in the template
      $error = true;
  } else {
    // nothing has been submitted
    // nothing has gone wrong
    $error = false;
  return array('error' => $error);

If it is a specific page, then why don’t you redirect to this page?

i´m planning to add another page on the same level + there are several ways to get to those protected pages

See this post among others: Frontend redirect to requested page after login