From e3b1dd7c10ccade6bd4cf4d9d3c94029589217b6 Mon Sep 17 00:00:00 2001 From: Josef Glatz <typo3@josefglatz.at> Date: Thu, 19 Jan 2023 12:27:49 +0100 Subject: [PATCH] [DOCS] Add hint about relative targets in redirects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch extends the documentation of typo3/cms-redirects by an example of redirecting to an relative target while using regular-expressions. This adds more clarity for TYPO3 integrators and administrators. Resolves: #99639 Releases: main, 11.5 Change-Id: I6f6e24b5cf0a378d0efe0c7266c9abf249559e7d Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77438 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech> --- .../redirects/Documentation/Usage/Index.rst | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/typo3/sysext/redirects/Documentation/Usage/Index.rst b/typo3/sysext/redirects/Documentation/Usage/Index.rst index d1e2c8717dd4..194df074ea27 100644 --- a/typo3/sysext/redirects/Documentation/Usage/Index.rst +++ b/typo3/sysext/redirects/Documentation/Usage/Index.rst @@ -242,23 +242,47 @@ Access tab Regex examples -------------- -Example 1: Source path with regular expression and capturing group. +Example 1: Source path with regular expression and capturing group +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ redirect -+-----------------------------------------+-----------------------+----------------------------+ -| Source Path | Is Regular Expression | target | -+-----------------------------------------+-----------------------+----------------------------+ -| `#^/path/([a-zA-Z]{1}[a-zA-Z0-9_/-]+)#` | true | https://mysite/newpath/$1 | -+-----------------------------------------+-----------------------+----------------------------+ ++-------------------------------------------------+-----------------------+----------------------------------------+ +| Source Path | Is Regular Expression | target | ++-------------------------------------------------+-----------------------+----------------------------------------+ +| `#^/path/([a-zA-Z]{1}[a-zA-Z0-9_/-]+)#` | true | :samp:`https://example.org/newpath/$1` | ++-------------------------------------------------+-----------------------+----------------------------------------+ with the following result: -+-------------------------------+----------------------------------+ -| URL | result URL | -+-------------------------------+----------------------------------+ -| https://mysite/path/something | https://mysite/newpath/something | -+-------------------------------+----------------------------------+ ++--------------------------------------------+-----------------------------------------------+ +| URL | result URL | ++--------------------------------------------+-----------------------------------------------+ +| :samp:`https://example.org/path/something` | :samp:`https://example.org/newpath/something` | ++--------------------------------------------+-----------------------------------------------+ + + +Example 2: Source path with regular expression, capturing group and relative target +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +redirect + ++-------------------------------------------------+-----------------------+---------------+ +| Source Path | Is Regular Expression | target | ++-------------------------------------------------+-----------------------+---------------+ +| `#^/another/path/([a-zA-Z]{1}[a-zA-Z0-9_/-]+)#` | true | `/newpath/$1` | ++-------------------------------------------------+-----------------------+---------------+ + +with the following result: + ++----------------------------------------------------+--------------------------------------------------------+ +| URL | result URL | ++----------------------------------------------------+--------------------------------------------------------+ +| :samp:`https://example.org/another/path/something` | :samp:`https://example.org/relative/newpath/something` | ++----------------------------------------------------+--------------------------------------------------------+ + +Using a relative target is necessary if a redirect must work on multiple domains or multiple environments. + .. important:: -- GitLab