Need an old URL to point somewhere new? Add a _redirects file to your site and we’ll serve
proper server-side 301 and 302 redirects — the real thing, sent by the server before your
page loads, not a slow client-side meta refresh.
The _redirects file
Create a plain text file named _redirects and make sure it ends up in your published
output (the folder we serve). One rule per line:
# Moved a page
/old-page /new-page 301
# Send an old section to a new one
/blog/* /articles/ 301
# A temporary redirect
/launch / 302
Each line is FROM TO [CODE]:
- FROM and TO are paths on your own site, starting with
/. - CODE is optional and defaults to 301 (permanent). Use 302 for a temporary move.
- A trailing
/*on FROM matches everything beneath that path. - Lines starting with
#are comments; blank lines are ignored.
Redirects take effect on your next deploy, and you can have up to 500 per site.
Getting _redirects into your output
The file has to be in the folder we publish, so it depends on your generator:
| Framework | Where to put it |
|---|---|
| Hugo | static/_redirects — Hugo copies everything in static/ to the output root. |
| Jekyll | Add _redirects to your repo and either list it under include: in _config.yml, or copy it after the build: jekyll build && cp _redirects _site/. |
| Static | Put _redirects in the directory you serve. |
You can confirm it shipped by opening https://yoursite/_redirects after a deploy.
Notes
- Redirects are same-site (path to path on your own domains). To move a whole domain to another, set your primary domain instead — we redirect the others to it automatically.
- If you’ve set a primary domain, test on it. Your other addresses (including the free
*.my.statichost.ukone) already redirect everything to the primary domain first, so your path rules apply once a request lands there. Checking a rule on themy.statichost.ukaddress will just show that whole-domain redirect, not your path rule. - 301s are cached hard by browsers. If you get one wrong, fix the
_redirectsline and redeploy, then test in a private window (your browser may have cached the old one).