# Redirect all requests to one URL

Redirect every incoming request to a single destination URL directly from Azion's global network. This is helpful during maintenance windows or downtime, when you want to point all visitors to a status page or an alternate site without changing your origin.

```js
  const destinationURL = "https://www.azion.com/en/"
  const statusCode = 301
  
  async function handleRequest(request) {
    return Response.redirect(destinationURL, statusCode)
  }
  
  addEventListener("fetch", async event => {
    event.respondWith(handleRequest(event.request))
  })
```

## How it works

The function registers a handler for the `fetch` event with `addEventListener`. Inside `handleRequest`, it calls `Response.redirect(destinationURL, statusCode)` to build a redirect response that points the browser to the configured URL, using the `301` status code to signal a permanent move. Because `destinationURL` and `statusCode` are constants, every request receives the same redirect regardless of the original path. `event.respondWith()` then returns that response, so visitors are redirected without the request ever reaching your origin.

## Related resources

- [JavaScript examples](/en/documentation/platform/functions/javascript-examples.md): Browse the other ready-to-use examples you can copy into a function.
- [FetchEvent](/en/documentation/devtools/runtime/api-reference/fetch-event.md): Reference for the `fetch` event that triggers the handler.
- [Response](/en/documentation/devtools/runtime/api-reference/response.md): Reference for `redirect()` and the rest of the response object.
- [Quickstart](/en/documentation/platform/functions/quickstart.md): What an account needs before a function can run, and the steps that put one in the path of a request.
- [Query usage data from Functions](/en/documentation/guides/platform/observability/query-functions-usage-data-with-graphql.md): Read back the compute time and the invocations this function has consumed.
- [Redirect To](/en/documentation/platform/applications/rules-engine.md#redirect-to): The Rules Engine behavior that redirects without a function, and the status codes it offers.
