Schema definition for the Redirect Plugin, which provides URL redirection with pattern matching and both request and response redirects.
Property | Value |
---|---|
Schema URL | https://rustybeam.net/schema/RedirectPlugin |
Parent Schema | https://rustybeam.net/schema/HandlerPlugin |
Description | URL redirection with regex pattern matching for both request and response redirects |
Property | Type | Cardinality | Description |
---|---|---|---|
rulesfile | https://rustybeam.net/schema/URL | 0..1 | Path to HTML file containing RedirectRule microdata. Supports file:// URLs. Contains redirect rules for pattern matching and URL rewriting. |
name | https://rustybeam.net/schema/Text | 0..1 | Plugin instance name for logging and identification. Defaults to "redirect" if not specified. |
<tr itemscope itemtype="https://rustybeam.net/schema/RedirectPlugin">
<span itemprop="library">file://./plugins/librusty_beam_redirect.so</span>
<span itemprop="rulesfile">file://./config/redirects.html</span>
</tr>
<tr itemscope itemtype="https://rustybeam.net/schema/RedirectPlugin">
<span itemprop="library">file://./plugins/librusty_beam_redirect.so</span>
<span itemprop="rulesfile">file://./examples/guestbook/config/server-config.html</span>
<span itemprop="name">main_redirects</span>
</tr>
The rules file referenced by rulesfile
should contain RedirectRule microdata:
<!-- Simple path redirect -->
<div itemscope itemtype="https://rustybeam.net/schema/RedirectRule">
<span itemprop="from">/old-path</span>
<span itemprop="to">/new-path</span>
<span itemprop="status">301</span>
</div>
<!-- Regex pattern with capture groups -->
<div itemscope itemtype="https://rustybeam.net/schema/RedirectRule">
<span itemprop="from">^/blog/(\d{4})/(\d{2})/(.+)$</span>
<span itemprop="to">/posts/$1-$2-$3</span>
<span itemprop="status">301</span>
<span itemprop="https_only">true</span>
</div>
<!-- Redirect on 403 Forbidden -->
<div itemscope itemtype="https://rustybeam.net/schema/RedirectRule">
<span itemprop="from">^/auth/.*$</span>
<span itemprop="to">/</span>
<span itemprop="status">302</span>
<span itemprop="on">403</span>
</div>
<!-- Handle multiple error codes -->
<div itemscope itemtype="https://rustybeam.net/schema/RedirectRule">
<span itemprop="from">^/api/.*$</span>
<span itemprop="to">/error?code=$code</span>
<span itemprop="status">302</span>
<span itemprop="on">403</span>
<span itemprop="on">500</span>
</div>
on
property)on
property)This schema inherits from the HandlerPlugin schema, which provides:
config_file
- Configuration file pathrulesfile
- Rules file path (used by RedirectPlugin)And ultimately from the base Plugin schema, which provides:
library
- Plugin library pathplugin
- Base plugin reference property<div itemscope itemtype="https://rustybeam.net/schema/RedirectRule">
<span itemprop="from">.*</span>
<span itemprop="to">https://$host$uri</span>
<span itemprop="status">301</span>
<span itemprop="https_only">false</span>
</div>
<div itemscope itemtype="https://rustybeam.net/schema/RedirectRule">
<span itemprop="from">^/(.*)$</span>
<span itemprop="to">https://www.example.com/$1</span>
<span itemprop="status">301</span>
<span itemprop="host_pattern">^(?!www\\.).*example\\.com$</span>
</div>
rulesfile
property should be a valid file path or file:// URLname
property should be unique if multiple redirect plugins are used