1. Overview
1.1 Plugin Name#
- Redirect Plugin
1.2 Appropriate Scenario#
- As the name suggests, the
redirectplugin is to re-forward and redirecturi.
1.3 Plugin functionality#
- When the Apache ShenYu gateway makes proxy calls to the target service, it also allows users to use the
redirectplugin to redirect requests.
1.4 Plugin code#
Core module shenyu-plugin-context-redirect
Core class org.apache.shenyu.plugin.redirect.RedirectPlugin
1.5 Added Since Which shenyu version#
before 2.2.0 .
2. How to use plugin
2.1 Plugin-use procedure chart#

2.2 Import pom#
import maven config in shenyu-bootstrap project's
pom.xmlfile.<!-- apache shenyu redirect plugin start--><dependency> <groupId>org.apache.shenyu</groupId> <artifactId>shenyu-spring-boot-starter-plugin-redirect</artifactId> <version>${project.version}</version></dependency><!-- apache shenyu redirect plugin end-->
2.3 Enable plugin#
In
shenyu-admin--> BasicConfig --> Plugin -->Redirectset Status enable.
2.4 Config plugin#
Selector and rule config, please refer: Selector and rule config.
In
shenyu-admin-->PluginList-->HttpProcess-->Redirect, add selector config first,then add rule config:Add selector config

Add rule config

2.5 Examples#
2.5.1 Redirect#
- When we configure a custom path in
Rule, it should be a reachable service path. - When the request is matched, the
ShenYu Gatewaywill perform the308service jump according to the customized path.
- Refer Local Deployment to start admin and bootstrap.
- Refer 2.2 to import pom and restart bootstrap.
- Refer 2.3 to enable plugin.
- Refer 2.4 and Selector and rule config.
- Invoke interface: demo
Invoke the interface declared by selectors and rules will redirect to the specified path.
In this demo, it will jump to ShenYu official website

2.5.2 Gateway's own interface forwarding#
When the matching rules are met, the service will use the
DispatcherHandlerinternal interface for forwarding.To implement the gateway's own interface forwarding, we need to use
/as the prefix in the configuration path. The specific configuration is as shown in the figure below.
3. How to disable plugin
In
shenyu-admin--> BasicConfig --> Plugin -->Redirectset Status disable.