protected function redirect()
    {
        $redirect = false;
        $file = $this->file('301.txt');
        if (is_file($file)) {
            $map = array();
            foreach (array_filter(array_map('trim', file($file))) as $url) {
                if ($url[0] == '[' && substr($url, -1) == ']') {
                    $new = substr($url, 1, -1);
                } elseif (isset($new) && !isset($map[$url])) {
                    $map[$url] = $new;
                }
            }
            $endless = array();
            $path = $this->url['path'];
            parse_str(ltrim($this->url['query'], '?'), $params);
            while ($route = $this->routes($map, $path)) { // get all redirects at once
                $path = $route['target'];
                $params += $route['params'];
                if (in_array($path, $endless) || count($endless) > 5) {
                    return false;
                } else {
                    $endless[] = $path;
                    $redirect = rtrim($path.'?'.http_build_query($params), '?');
                }
            }
        }

        return $redirect;
    }