@loopback/docs
Version:
Documentation for LoopBack 4
44 lines (27 loc) • 1.23 kB
Markdown
lang: en
title: 'API docs: rest.restapplication.redirect'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.rest.restapplication.redirect.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/rest](./rest.md) > [RestApplication](./rest.restapplication.md) > [redirect](./rest.restapplication.redirect.md)
## RestApplication.redirect() method
Register a route redirecting callers to a different URL.
<b>Signature:</b>
```typescript
redirect(fromPath: string, toPathOrUrl: string, statusCode?: number): Binding;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| fromPath | <code>string</code> | URL path of the redirect endpoint |
| toPathOrUrl | <code>string</code> | Location (URL path or full URL) where to redirect to. If your server is configured with a custom <code>basePath</code>, then the base path is prepended to the target location. |
| statusCode | <code>number</code> | HTTP status code to respond with, defaults to 303 (See Other). |
<b>Returns:</b>
`Binding`
## Example
```ts
app.redirect('/explorer', '/explorer/');
```