2023-03-30 21:36:31 +00:00
|
|
|
# Features
|
|
|
|
|
|
|
|
## Custom domains
|
|
|
|
|
2023-11-15 17:59:04 +00:00
|
|
|
Custom domains can be used by creating a `.domains` file with the domain name, e.g.:
|
|
|
|
|
|
|
|
```text
|
|
|
|
codeberg.page
|
|
|
|
```
|
|
|
|
|
|
|
|
You also have to set some DNS records, see the [Codeberg Documentation](https://docs.codeberg.org/codeberg-pages/using-custom-domain/).
|
2023-03-30 21:36:31 +00:00
|
|
|
|
|
|
|
## Redirects
|
|
|
|
|
|
|
|
Redirects can be created with a `_redirects` file with the following format:
|
|
|
|
|
2023-11-15 17:59:04 +00:00
|
|
|
```text
|
2023-03-30 21:36:31 +00:00
|
|
|
# Comment
|
|
|
|
from to [status]
|
|
|
|
```
|
|
|
|
|
2024-04-28 20:47:04 +00:00
|
|
|
- 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 to
|
|
|
|
- `status` - status code to use when redirecting (default 301)
|
2023-03-30 21:36:31 +00:00
|
|
|
|
|
|
|
### Status codes
|
|
|
|
|
2024-04-28 20:47:04 +00:00
|
|
|
- `200` - returns content from specified path (no external URLs) without changing the URL (rewrite)
|
|
|
|
- `301` - Moved Permanently (Permanent redirect)
|
|
|
|
- `302` - Found (Temporary redirect)
|
2023-03-30 21:36:31 +00:00
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
|
|
#### SPA (single-page application) rewrite
|
|
|
|
|
|
|
|
Redirects all paths to `/index.html` for single-page apps.
|
|
|
|
|
2023-11-15 17:59:04 +00:00
|
|
|
```text
|
2023-03-30 21:36:31 +00:00
|
|
|
/* /index.html 200
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Splats
|
|
|
|
|
|
|
|
Redirects every path under `/articles` to `/posts` while keeping the path.
|
|
|
|
|
2023-11-15 17:59:04 +00:00
|
|
|
```text
|
2023-03-30 21:36:31 +00:00
|
|
|
/articles/* /posts/:splat 302
|
|
|
|
```
|
|
|
|
|
|
|
|
Example: `/articles/2022/10/12/post-1/` -> `/posts/2022/10/12/post-1/`
|