Skip to content

Commit bc288ac

Browse files
committed
Clarify clean URL behavior for flat pages and folder indexes
1 parent 6e79185 commit bc288ac

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎content/(serve)/routing.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ There is no generic trailing-slash normalizer. The behavior comes from what the
209209

210210
| Situation | Behavior |
211211
| --- | --- |
212-
| `dir/index.html` exists | `/dir/` serves; `/dir`, `/dir/index` and `/dir/index.html` answer 308 to `/dir/` |
212+
| `dir/index.html` exists | `/dir/` serves and `/dir` answers 308 to `/dir/`. With clean URLs on, `/dir/index` and `/dir/index.html` also redirect there |
213213
| A directory listing exists for `dir` | `/dir/` serves, `/dir` answers 308 to `/dir/` |
214214
| Clean URLs are on and `page.html` exists | `/page` serves; `/page/` and `/page.html` answer 308 to `/page` |
215215
| Anything else | No normalization. The other spelling falls through to the SPA fallback or a 404 |
@@ -218,7 +218,7 @@ Those compiled 308s accept every method and carry the incoming query across.
218218

219219
## Index files and clean URLs
220220

221-
`index.html` at the root answers `/`. `docs/index.html` answers `/docs/`, and `/docs`, `/docs/index` and `/docs/index.html` redirect there with a 308. With clean URLs on, each page has one URL, as on Cloudflare Pages. A folder always serves its own `index.html`, the file every static site generator and framework writes for a folder.
221+
`index.html` at the root answers `/`. `docs/index.html` answers `/docs/`, and `/docs` redirects there with a 308. With clean URLs on, `/docs/index` and `/docs/index.html` also redirect there. A folder always serves its own `index.html`, the file every static site generator and framework writes for a folder.
222222

223223
With no `index` set, Spacefast infers the homepage: a root `index.html`, else the file a 200 `fallback` names (unless the version runs a worker, which keeps `/`), else a single public HTML file, else the one root-level HTML file, else none, which puts the Space in files mode with directory listings.
224224

@@ -233,7 +233,7 @@ Two keys in `sf.jsonc` change it:
233233

234234
`index` names the homepage, the file `/` serves. It doesn't rename folder indexes: with `"index": "home.html"`, `docs/home.html` doesn't answer `/docs/`, and the publish warns with `custom_index_not_folder_index`. Setting it to `false` serves no homepage.
235235

236-
`cleanUrls` serves a flat `about.html` at `/about`, and redirects `/about.html` and `/about/` there with a 308, query string included. A rewrite that lands on `/about.html` still serves the file, and a page you address with your own redirect or `_headers` rule keeps its `.html` URL. With `"cleanUrls": false`, pages answer only at their file URL. It defaults to on, with or without a fallback, so a committed page always wins its URL over the SPA shell.
236+
`cleanUrls` serves a flat `about.html` at `/about`, and redirects `/about.html` and `/about/` there with a 308, query string included. A rewrite that lands on `/about.html` still serves the file, and a page you address with your own redirect or `_headers` rule keeps its `.html` URL. With `"cleanUrls": false`, flat pages answer only at their file URL. Folders still serve their `index.html` at the folder URL: `/docs/` serves and `/docs` redirects there. The literal `/docs/index.html` also serves, while `/docs/index` has no generated alias. `cleanUrls` defaults to on, with or without a fallback, so a committed page always wins its URL over the SPA shell.
237237

238238
In a config that declares `"version": 1`, these live under `serve` as `serve.index`, `serve.cleanUrls`, `serve.spaFallback`, and `serve.directoryListing`.
239239

0 commit comments

Comments
 (0)