Skip to content

Commit 9ebd216

Browse files
committed
Use * and :splat syntax
1 parent 68fa2f9 commit 9ebd216

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

docs/dev/design/redirects.rst

+25-15
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,22 @@ all other redirects need to be matched as is.
188188

189189
This makes it impossible to match a path with a trailing slash.
190190

191-
Explicit ``$rest`` placeholder
192-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191+
Use ``*`` and ``:splat`` for wildcards
192+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193193

194-
Explicitly place the ``$rest`` placeholder in the target URL,
194+
Currently we are using ``$rest`` at the end of the ``From URL``
195+
to indicate that the rest of the path should be added to the target URL.
196+
197+
A similar feature is implemented in other services using ``*`` and ``:splat``.
198+
199+
Instead of using ``$rest`` in the URL for the suffix wildcard, we now will use ``*``,
200+
and ``:splat`` as a placeholder in the target URL to be more consistent with other services.
201+
Existing redirects can be migrated automatically.
202+
203+
Explicit ``:splat`` placeholder
204+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205+
206+
Explicitly place the ``:splat`` placeholder in the target URL,
195207
instead of adding it automatically.
196208

197209
Some times users want to redirect to a different path,
@@ -200,18 +212,18 @@ prevent the old path from being added in the final path.
200212
For example ``/new/path/?_=``.
201213

202214
Instead of adding the path automatically,
203-
users have to add the ``$rest`` placeholder in the target URL.
215+
users have to add the ``:splat`` placeholder in the target URL.
204216
For example:
205217

206218
From:
207-
``/old/path/$rest``
219+
``/old/path/*``
208220
To:
209-
``/new/path/$rest``
221+
``/new/path/:splat``
210222

211223
From:
212-
``/old/path/$rest``
224+
``/old/path/*``
213225
To:
214-
``/new/path/?page=$rest&foo=bar``
226+
``/new/path/?page=:splat&foo=bar``
215227

216228
Improving page redirects
217229
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -237,16 +249,16 @@ Improving page redirects
237249
This will allow users to migrate a whole directory to a new path
238250
without having to create an exact redirect for each version.
239251

240-
Similar to exact redirects, users need to add the ``$rest`` placeholder explicitly.
252+
Similar to exact redirects, users need to add the ``:splat`` placeholder explicitly.
241253
This means that that page redirects are the same as exact redirects,
242254
with the only difference that they apply to all versions.
243255

244256
Example:
245257

246258
From:
247-
``/old/path/$rest``
259+
``/old/path/*``
248260
To:
249-
``/new/path/$rest``
261+
``/new/path/:splat``
250262

251263
Improving Sphinx redirects
252264
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -262,6 +274,8 @@ Proposed names:
262274
Other ideas to improve redirects
263275
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
264276

277+
The following improvements will not be implemented in the first iteration.
278+
265279
- Run forced redirects before built-in redirects.
266280
We currently run built-in redirects before forced redirects,
267281
this is a problem when moving a whole project to a new domain.
@@ -293,10 +307,6 @@ Other ideas to improve redirects
293307
We can consider adding it in the future.
294308
Maybe we can expose the current language and version as placeholders.
295309

296-
- Replace ``$rest`` with ``*`` in the from_url.
297-
This will be more consistent with other services,
298-
but it will require users to re-learn the feature.
299-
300310
- Per-protocol redirects.
301311
We should push users to always use HTTPS.
302312

0 commit comments

Comments
 (0)