Redirect to directory's index.html
519189
function redirect() {
                var resultURL = urlTransform(req.url, function(parsed) {
                    parsed.pathname += '/';
                    return parsed;
                });

                res.statusCode = 301;
                res.setHeader('Location', resultURL);
                res.end('Redirecting to ' + resultURL);
            }
574359
def redirect(location, code=302, **kw):
    """"""
    if not 300 <= code < 400:
        raise ValueError("Not a 3xx status code: '%s'" % code)
    return response(code=code, location=location, **kw)
56224
function(dirname, next) {
        // could be something
        searchDir += dirname + '/';

        var revPath = version && (searchDir + version + '.js');
        return next(null, revPath || '');
      }
41347
def include_path(self):
        
        parts = [self.include_dir(root=self.url_root)]
        parts.append("index")
        return "/".join(parts)
246222
def _relIndexLink(self):
        """"""
        return os.path.join("..", os.path.basename(self.pathname), "index.html")
709190
def render_index_file!(uri_path)
      return unless URI.directory?(uri_path)

      index_match     = File.join(settings.public_dir, "*")
      index_file_path = File.expand_path(uri_path + "index.html", settings.public_dir)

      return unless File.fnmatch(index_match, index_file_path)
      return unless File.file?(index_file_path)

      send_file index_file_path
    end
827112
def _add_redirects(self):
        
        html = '''
        <html>
            <head>
                <meta http-equiv="refresh" content="0;URL={url}"/>
            </head>
            <body>
                <p>
                    The page has been moved to <a href="{url}">{title}</a>
                </p>
            </body>
        <html>
        '''
        with open(REDIRECTS_FILE) as mapping_fd:
            reader = csv.reader(mapping_fd)
            for row in reader:
                if not row or row[0].strip().startswith('#'):
                    continue

                path = os.path.join(BUILD_PATH,
                                    'html',
                                    *row[0].split('/')) + '.html'

                try:
                    title = self._get_page_title(row[1])
                except Exception:
                    # the file can be an ipynb and not an rst, or docutils
                    # may not be able to read the rst because it has some
                    # sphinx specific stuff
                    title = 'this page'

                if os.path.exists(path):
                    raise RuntimeError((
                        'Redirection would overwrite an existing file: '
                        '{}').format(path))

                with open(path, 'w') as moved_page_fd:
                    moved_page_fd.write(
                        html.format(url='{}.html'.format(row[1]),
                                    title=title))
737500
function renderDirectory(cwd, dir, res){
  var content = '';
  content += '<h1>Index of '+ dir.replace(cwd, '') +'</h1>';
  content += '<hr />';
  fs.readdir(dir, function(err, files){
    content += '<table width="50%">';
    content += '<tr>';
    content += '<td><a href="..">../</a></td>';
    content += '</tr>';
    files.map(function(filename){
      var stat = fs.statSync(path.join(dir, filename));
      filename = filename +  (stat.isDirectory() ? '/' : '');
      content += '<tr>';
      content += '<td><a href="' + filename + '">' + filename + '</a></td>';
      content += '<td>' + (stat.mtime || '-')      +                '</td>';
      content += '<td>' + (stat.size        )      +                '</td>';
      content += '</tr>';
    }).join('');
    content += '</table>';
    content += '<hr/>';
    content += 'Powered by <a href="https://github.com/song940/kelp-static" >kelp-static</a>';
    res.setHeader('Content-Type', 'text/html');
    res.end(content);
  });
}
413803
function topLevelRedirect (url) {
  if (window === top) location.href = url
  else parent.postMessage('slackin-redirect:' + id + ':' + url, '*')
  // Q: Why can't we just `top.location.href = url;`?
  // A:
  // [sandboxing]: http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
  // [CSP]: http://www.html5rocks.com/en/tutorials/security/content-security-policy/
  // [nope]: http://output.jsbin.com/popawuk/16
}
341919
function getRedirectTo(options, page) {
    if( typeof options === 'string' ) {
        options = {redirectTo: options};
    }
    options = options || {};
    page = page || 'root';
    return options.redirectTo || defaults[page];
}
960305
function(request, parent) {
      var path = expand(dirname(parent), request);
      if (_definedModules.hasOwnProperty(path)) return path;
      path = expand(path, './index');
      if (_definedModules.hasOwnProperty(path)) return path;
      return request;
    }
332737
protected function redirect()
    {
        $GLOBALS['eZRedirection'] = true;
        $ini = eZINI::instance();
        $automaticRedirect = true;

        if ( $GLOBALS['eZDebugAllowed'] && ( $redirUri = $ini->variable( 'DebugSettings', 'DebugRedirection' ) ) !== 'disabled' )
        {
            if ( $redirUri == "enabled" )
            {
                $automaticRedirect = false;
            }
            else
            {
                $uri = eZURI::instance( eZSys::requestURI() );
                $uri->toBeginning();
                foreach ( $ini->variableArray( "DebugSettings", "DebugRedirection" ) as $redirUri )
                {
                    $redirUri = new eZURI( $redirUri );
                    if ( $redirUri->matchBase( $uri ) )
                    {
                        $automaticRedirect = false;
                        break;
                    }
                }
            }
        }

        $redirectURI = eZSys::indexDir();

        $moduleRedirectUri = $this->module->redirectURI();
        if ( $ini->variable( 'URLTranslator', 'Translation' ) === 'enabled' &&
                eZURLAliasML::urlTranslationEnabledByUri( new eZURI( $moduleRedirectUri ) ) )
        {
            $translatedModuleRedirectUri = $moduleRedirectUri;
            if ( eZURLAliasML::translate( $translatedModuleRedirectUri, true ) )
            {
                $moduleRedirectUri = $translatedModuleRedirectUri;
                if ( strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] !== '/' )
                    $moduleRedirectUri = '/' . $moduleRedirectUri;
            }
        }

        if ( preg_match( '#^(\w+:)|^//#', $moduleRedirectUri ) )
        {
            $redirectURI = $moduleRedirectUri;
        }
        else
        {
            $leftSlash = strlen( $redirectURI ) > 0 && $redirectURI[strlen( $redirectURI ) - 1] === '/';
            $rightSlash = strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] === '/';

            if ( !$leftSlash && !$rightSlash ) // Both are without a slash, so add one
                $moduleRedirectUri = '/' . $moduleRedirectUri;
            else if ( $leftSlash && $rightSlash ) // Both are with a slash, so we remove one
                $moduleRedirectUri = substr( $moduleRedirectUri, 1 );

            // In some cases $moduleRedirectUri can already contain $redirectURI (including the siteaccess).
            if ( !empty( $redirectURI ) && strpos( $moduleRedirectUri, $redirectURI ) === 0 )
            {
                $redirectURI = $moduleRedirectUri;
            }
            else
            {
                $redirectURI .= $moduleRedirectUri;
            }
        }

        // After the module redirect url is completed, add the queryString params so they carry over the redirect operation
        $redirectURI .= eZSys::queryString();

        if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' )
        {
            $staticCacheHandlerClassName = $ini->variable( 'ContentSettings', 'StaticCacheHandler' );
            $staticCacheHandlerClassName::executeActions();
        }

        eZDB::checkTransactionCounter();

        if ( !$automaticRedirect )
        {
            // Make sure any errors or warnings are reported
            if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) === 'enabled' )
            {
                if ( isset( $GLOBALS['eZDebugError'] ) && $GLOBALS['eZDebugError'] )
                {
                    eZAppendWarningItem(
                        array(
                            'error' => array(
                                'type' => 'error',
                                'number' => 1,
                                'count' => $GLOBALS['eZDebugErrorCount']
                            ),
                            'identifier' => 'ezdebug-first-error',
                            'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' )
                        )
                    );
                }

                if ( isset( $GLOBALS['eZDebugWarning'] ) && $GLOBALS['eZDebugWarning'] )
                {
                    eZAppendWarningItem(
                        array(
                            'error' => array(
                                'type' => 'warning',
                                'number' => 1,
                                'count' => $GLOBALS['eZDebugWarningCount']
                            ),
                            'identifier' => 'ezdebug-first-warning',
                            'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' )
                        )
                    );
                }
            }

            $tpl = eZTemplate::factory();
            $tpl->setVariable( 'site', $this->site );
            $tpl->setVariable( 'warning_list', !empty( $this->warningList ) ? $this->warningList : false );
            $tpl->setVariable( 'redirect_uri', eZURI::encodeURL( $redirectURI ) );
            $templateResult = $tpl->fetch( 'design:redirect.tpl' );

            eZDebug::addTimingPoint( "Script end" );

            eZDisplayResult( $templateResult );
            eZExecution::cleanExit();
        }

        return eZHTTPTool::redirect( $redirectURI, array(), $this->module->redirectStatus(), true, true );
    }
377877
def create_redirect_web_page(web_dir, org_name, kibana_url):
    
    html_redirect = """
    <html>
        <head>
    """
    html_redirect += """<meta http-equiv="refresh" content="0; URL=%s/app/kibana"""\
                     % kibana_url
    html_redirect += """#/dashboard/Overview?_g=(filters:!(('$state':"""
    html_redirect += """(store:globalState),meta:(alias:!n,disabled:!f,index:"""
    html_redirect += """github_git_enrich,key:project,negate:!f,value:%s),"""\
                     % org_name
    html_redirect += """query:(match:(project:(query:%s,type:phrase))))),"""\
                     % org_name
    html_redirect += """refreshInterval:(display:Off,pause:!f,value:0),"""
    html_redirect += """time:(from:now-2y,mode:quick,to:now))" />
        </head>
    </html>
    """
    try:
        with open(path.join(web_dir, org_name), "w") as f:
            f.write(html_redirect)
    except FileNotFoundError as ex:
        logging.error("Wrong web dir for redirect pages: %s" % (web_dir))
        logging.error(ex)
386686
def _join_url_dir(self, url, *args):
        
        for path in args:
            url = url.rstrip('/') + '/'
            url = urljoin(url, path.lstrip('/'))

        return url
1078122
function createRedirectDirectoryListener () {
  return function redirect (res) {
    if (this.hasTrailingSlash()) {
      this.error(404)
      return
    }

    // get original URL
    var originalUrl = parseUrl.original(this.req)

    // append trailing slash
    originalUrl.path = null
    originalUrl.pathname = collapseLeadingSlashes(originalUrl.pathname + '/')

    // reformat the URL
    var loc = encodeUrl(url.format(originalUrl))
    var doc = createHtmlDocument('Redirecting', 'Redirecting to <a href="' + escapeHtml(loc) + '">' +
      escapeHtml(loc) + '</a>')

    // send redirect response
    res.statusCode = 301
    res.setHeader('Content-Type', 'text/html; charset=UTF-8')
    res.setHeader('Content-Length', Buffer.byteLength(doc))
    res.setHeader('Content-Security-Policy', "default-src 'self'")
    res.setHeader('X-Content-Type-Options', 'nosniff')
    res.setHeader('Location', loc)
    res.end(doc)
  }
}
1018537
function(req, res, next) {

        /**
         * If you want to redirect to another controller, uncomment
         */

        var controllers = [];

        fs.readdir(__dirname + '/', function(err, files) {

            if (err) {
                throw err;
            }
            files.forEach(function(file) {
                if(/\.js$/i.test(file)) {
                   if (file !== "AppsController.js") {
                       controllers.push(file.replace('Controller.js', '').toLowerCase());
                   }
                }
            });

            res.render('app', {
                controllers: controllers
            });

        });
    }
651336
def resource_redirect(id):
    '''
    
    '''
    resource = get_resource(id)
    return redirect(resource.url.strip()) if resource else abort(404)