original_string: public function redirect($route, $code = null)
      {
          /** @var Uri $uri */
          $uri = $this['uri'];
  
          //Check for code in route
          $regex = '/.*(\[(30[1-7])\])$/';
          preg_match($regex, $route, $matches);
          if ($matches) {
              $route = str_replace($matches[1], '', $matches[0]);
              $code = $matches[2];
          }
  
          if ($code === null) {
              $code = $this['config']->get('system.pages.redirect_default_code', 302);
          }
  
          if (isset($this['session'])) {
              $this['session']->close();
          }
  
          if ($uri->isExternal($route)) {
              $url = $route;
          } else {
              $url = rtrim($uri->rootUrl(), '/') . '/';
  
              if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
                  $url .= trim($route, '/'); // Remove trailing slash
              } else {
                  $url .= ltrim($route, '/'); // Support trailing slash default routes
              }
          }
  
          header("Location: {$url}", true, $code);
          exit();
      }
code: public function redirect($route, $code = null)
      {
          /** @var Uri $uri */
          $uri = $this['uri'];
  
          //Check for code in route
          $regex = '/.*(\[(30[1-7])\])$/';
          preg_match($regex, $route, $matches);
          if ($matches) {
              $route = str_replace($matches[1], '', $matches[0]);
              $code = $matches[2];
          }
  
          if ($code === null) {
              $code = $this['config']->get('system.pages.redirect_default_code', 302);
          }
  
          if (isset($this['session'])) {
              $this['session']->close();
          }
  
          if ($uri->isExternal($route)) {
              $url = $route;
          } else {
              $url = rtrim($uri->rootUrl(), '/') . '/';
  
              if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
                  $url .= trim($route, '/'); // Remove trailing slash
              } else {
                  $url .= ltrim($route, '/'); // Support trailing slash default routes
              }
          }
  
          header("Location: {$url}", true, $code);
          exit();
      }
code_tokens: public function redirect ( $ route , $ code = null ) { /** @var Uri $uri */ $ uri = $ this [ 'uri' ] ; //Check for code in route $ regex = '/.*(\[(30[1-7])\])$/' ; preg_match ( $ regex , $ route , $ matches ) ; if ( $ matches ) { $ route = str_replace ( $ matches [ 1 ] , '' , $ matches [ 0 ] ) ; $ code = $ matches [ 2 ] ; } if ( $ code === null ) { $ code = $ this [ 'config' ] -> get ( 'system.pages.redirect_default_code' , 302 ) ; } if ( isset ( $ this [ 'session' ] ) ) { $ this [ 'session' ] -> close ( ) ; } if ( $ uri -> isExternal ( $ route ) ) { $ url = $ route ; } else { $ url = rtrim ( $ uri -> rootUrl ( ) , '/' ) . '/' ; if ( $ this [ 'config' ] -> get ( 'system.pages.redirect_trailing_slash' , true ) ) { $ url .= trim ( $ route , '/' ) ; // Remove trailing slash } else { $ url .= ltrim ( $ route , '/' ) ; // Support trailing slash default routes } } header ( "Location: {$url}" , true , $ code ) ; exit ( ) ; }
docstring: Redirect browser to another location.
  
  @param string $route Internal route.
  @param int    $code  Redirection code (30x)
docstring_tokens: Redirect browser to another location .