mirror of
https://codeberg.org/Codeberg/Documentation.git
synced 2026-06-17 22:03:51 -07:00
Documentation for redirects on Codeberg Pages: https://codeberg.org/Codeberg/pages-server/pulls/148 Co-authored-by: video-prize-ranch <cb.8a3w5@simplelogin.co> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/Codeberg/Documentation/pulls/294 Co-authored-by: video-prize-ranch <video-prize-ranch@noreply.codeberg.org> Co-committed-by: video-prize-ranch <video-prize-ranch@noreply.codeberg.org>
1.1 KiB
1.1 KiB
| eleventyNavigation | ||||||||
|---|---|---|---|---|---|---|---|---|
|
Redirects can be created with a _redirects file with the following format:
# Comment
from to [status]
- Lines starting with
#are ignored from- the path to redirect from (Note: repository and branch names are removed from request URLs)to- the path or URL to redirect tostatus- status code to use when redirecting (default 301)
Status codes
200- returns content from specified path (no external URLs) without changing the URL (rewrite)301- Moved Permanently (Permanent redirect)302- Found (Temporary redirect)
Examples
Simple redirect
Redirects a specific path.
/example https://example.com/ 301
/path /other-path 301
SPA (single-page application) rewrite
Redirects all paths to /index.html for single-page apps.
/* /index.html 200
Splats
Redirects every path under /articles to /posts while keeping the path.
/articles/* /posts/:splat 302
Example: /articles/2022/10/12/post-1/ -> /posts/2022/10/12/post-1/