---
url: >-
  https://lit-ui-router.dev/reference/ui-router-server/prerender/functions/redirectPages.md
---
[ui-router-server](../../index.md) / [prerender](../index.md) / redirectPages

# Function: redirectPages()

```ts
function redirectPages(options?): RulesWriter;
```

Defined in: [redirect-pages.ts:144](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-server/src/redirect-pages.ts#L144)

A [\`rules\`](../interfaces/PrerenderOptions.md#rules) writer for static hosts with no
redirect rules, such as GitHub Pages or a plain bucket: each line becomes
a page at `<from>/index.html` that sends the browser to its `to`. The page
answers 200, so the line's status never reaches the host; its canonical
link tells search engines the content moved.

The first line for a page wins, as in `_redirects`, so a path's two
spellings share one page. A line between a path's two spellings, as a
mount's trailing-slash policy adds, writes nothing: its page would be its
target's own, and the host serves that at both spellings.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options?` | [`RedirectPagesOptions`](../interfaces/RedirectPagesOptions.md) | the base `outDir` is served at, whether to write `_redirects` too, and the page template |

## Returns

[`RulesWriter`](../type-aliases/RulesWriter.md)

the writer to pass as `rules`

## Throws

an `Error`, when the writer runs, for a line whose page would replace one `prerender` wrote

## Throws

an `Error`, when the writer runs, for a line whose `from` is a pattern or lies outside `base`

## Example

```ts
import {
  prerender,
  type PrerenderOptions,
  redirectPages,
} from 'ui-router-server/prerender';

declare const { mounts, paths, render, write }: PrerenderOptions;

await prerender({ mounts, outDir: 'dist', paths, render, write, rules: redirectPages() });
```
