You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the `trailingSlash` option is set to `always` or `never`, on-demand rendered pages will now redirect to the correct URL when the trailing slash doesn't match the configuration option. This was previously the case for static pages, but now works for on-demand pages as well.
8
+
9
+
Now, it doesn't matter whether your visitor navigates to `/about/`, `/about`, or even `/about///`. In production, they'll always end up on the correct page. For GET requests, the redirect will be a 301 (permanent) redirect, and for all other request methods, it will be a 308 (permanent, and preserve the request method) redirect.
10
+
11
+
In development, you'll see a helpful 404 page to alert you of a trailing slash mismatch so you can troubleshoot routes.
body: `<p>Your site is configured with <code>trailingSlash</code> set to <code>${trailingSlash}</code>. Do you want to go to <a href="${corrected}">${corrected}</a> instead?</p>
144
+
<p>See <a href=https://docs.astro.build/en/reference/configuration-reference/#trailingslash">the documentation for <code>trailingSlash</code></a> if you need help.</p>`,
* Set the route matching behavior of the dev server. Choose from the following options:
240
-
* - `'always'` - Only match URLs that include a trailing slash (ex: "/foo/")
241
-
* - `'never'` - Never match URLs that include a trailing slash (ex: "/foo")
242
-
* - `'ignore'` - Match URLs regardless of whether a trailing "/" exists
243
-
*
244
-
* Use this configuration option if your production host has strict handling of how trailing slashes work or do not work.
245
-
*
246
-
* You can also set this if you prefer to be more strict yourself, so that URLs with or without trailing slashes won't work during development.
239
+
* Set the route matching behavior for trailing slashes in the dev server and on-demand rendered pages. Choose from the following options:
240
+
* - `'ignore'` - Match URLs regardless of whether a trailing "/" exists. Requests for "/about" and "/about/" will both match the same route.
241
+
* - `'always'` - Only match URLs that include a trailing slash (e.g: "/about/"). In production, requests for on-demand rendered URLs without a trailing slash will be redirected to the correct URL for your convenience. However, in development, they will display a warning page reminding you that you have `always` configured.
242
+
* - `'never'` - Only match URLs that do not include a trailing slash (e.g: "/about"). In production, requests for on-demand rendered URLs with a trailing slash will be redirected to the correct URL for your convenience. However, in development, they will display a warning page reminding you that you have `never` configured.
243
+
*
244
+
* When redirects occur in production for GET requests, the redirect will be a 301 (permanent) redirect. For all other request methods, it will be a 308 (permanent, and preserve the request method) redirect.
245
+
*
246
+
* Trailing slashes on prerendered pages are handled by the hosting platform, and may not respect your chosen configuration.
247
+
* See your hosting platform's documentation for more information.
0 commit comments