bneradt commented on code in PR #12730:
URL: https://github.com/apache/trafficserver/pull/12730#discussion_r2608049599
##########
doc/admin-guide/plugins/regex_remap.en.rst:
##########
@@ -171,3 +182,54 @@ as a redirect (Location:).
You can also combine multiple options, including overridable configs ::
^/(.*)?$ https://example.com/sitemaps/$1
@proxy.config.url_remap.pristine_host_hdr=0 @status=301
+
+Examples
+~~~~~~~~
+
+**Example: Basic path rewriting**
+
+By default, regex_remap matches against the URL path and query string, which
+always starts with ``/``. This example rewrites requests from an old URL
+structure to a new one::
+
+ # remap.config:
+ map http://www.example.com http://backend.example.com
@plugin=regex_remap.so @pparam=rewrites.conf
+
+ # rewrites.conf:
+ ^/old/(.*)$ http://backend.example.com/new/$1
+
+A request to ``http://www.example.com/old/page.html`` will be rewritten to
+``http://backend.example.com/new/page.html``. The ``$1`` substitution captures
+the first parenthesized group from the regex match.
+
+**Example: HTTP to HTTPS redirect with host matching**
+
+To redirect all HTTP requests to HTTPS while preserving the host and path,
+use the ``host`` option. With ``@pparam=host``, the match string is
+``//host/path?query`` (note the ``//`` prefix), so the following rule captures
+the entire string and redirects to HTTPS. Because the captured group includes
+the ``//``, the substitution uses ``https:`` without ``//`` to avoid producing
+a malformed URL with four slashes::
+
+ # remap.config:
+ regex_map http://(.*) https://unused.invalid @plugin=regex_remap.so
@pparam=redirect.conf @pparam=host @pparam=pristine
+
+ # redirect.conf:
+ ^(.*)$ https:$1 @status=307
+
+This will redirect ``http://example.com/path`` to ``https://example.com/path``.
Review Comment:
Good point. I updated and pushed a commit on top of this rewording the
paragraph to make this clearer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]