redirect
Immediately redirect matching requests (302 Found) to the specified URL without requesting the backend server.
Rule Syntax
txt
pattern redirect://targetUrl [filters...]
Parameters | Description | Detailed Documentation |
---|---|---|
pattern | Expression to match the request URL | Match Pattern Documentation |
targetUrl | The URL to redirect to, which can be a relative path | |
filters | Optional filters, supporting matching: • Request URL/Method/Headers/Content • Response Status Code/Headers | Filter Documentation |
Configuration Example
Basic Configuration
txt
www.example.com/path redirect://https://www.qq.com
www.example.com/path2 redirect://../abc/123
- Visit
https://www.example.com/path/to
and redirect tohttps://www.qq.com
(no automatic path concatenation) - Visit
https://www.example.com/path2/to
redirects tohttps://www.example.com/abc/123
Implementing path concatenation
txt
# Wildcard
^www.example.com/path/*** redirect://`https://www.example.com/$1`
- Visit
https://www.example.com/path/to?query
redirects tohttps://www.example.com/to?query
Associated Protocols
- Pages whose addresses cannot be modified via
302
can use: locationHref