---
search:
  tags:
    - sites
    - PUT
seo:
  description: >-
    Replaces all of the site's path redirects with redirects; an empty list
    removes… Reference for the PUT /v1/sites/{site}/redirects endpoint in the
    pols.so API.
sidebar:
  label: Replace a site's path redirects
  badge: PUT
title: Replace a site's path redirects
type: openapi-operation
---
Replaces all of the site's path redirects with `redirects`; an
empty list removes them. A rule answers a GET or HEAD of its `from`
with `status` (301, the default, or 302) and `to` as its
`Location` instead of the site's files, so old URLs of a moved site
keep working while it serves its new files.

`from` is a path starting with `/`, optionally with a query. A rule
without a query matches its path whatever the request's query; one
with a query matches only that query, its parameters in any order
(`/?p=12` matches `/?p=12`, not `/?p=12&x=1`). A request with a
query is matched with it first, then by its path alone. Paths are
compared decoded and case-sensitively, and a trailing slash is
ignored on both sides: `/hello-world/` and `/hello-world` are the
same. There are no wildcards.

`to` is a path on the same host, starting with `/`, or an absolute
`http` or `https` URL without a user name or password, used as it
is: the request's query is not carried over. A rule may not
redirect to itself, and two rules may not have the same `from`.
A site has at most 5000 rules; `from` is at most 1024 characters
and `to` at most 2048. The request body is at most 4 MiB.

The rules belong to the site, not to a version: publishing keeps
them. They apply on every host of the site, its custom domains
included, to whoever the site's access lets in, after its login
and share links, plain HTTP's redirect to HTTPS and a custom
domain's to the primary one. A site-wide `redirect_url` (`PATCH
/v1/sites/{site}`) wins over them, and a server app answers its own
requests: the rules apply to sites that serve files.

`PUT /v1/sites/{site}/redirects`
