Redirect is a common function that resembles the rewrite directive in NGINX, but is simpler and easier to understand.
It is the Page Rules. Directly create a Page Rules to understand
how to use Redirect which belongs to
Page Rules of the application.
Among the many options in the
Action drop-down list, drop down to
“Response Action” and select Redirect.
Redirect involves the following parameters:
URL: Current URL is the default with no changes. But the drop-down box offers user-defined setting to enter another URL;
URL Parameter: The default is no parameters, but if needed, the current URL or user-defined parameter is optional;
Protocol: The default option is the protocol of the current request, but http or https could be optional as well;
Host Name: Host name of the current request is the default, but the host name can also be user-defined;
Port: Port 80 is the default for http protocol port, port 443 is the default for https protocol port, or user-defined;
Code: 302 is the default code or other options from the drop-down box could also be selected;
The example below shows how to redirect http requests to https, without extra changes:
Set conditions and then redirect:
Now, verify whether the limit rule works or not.
First, enter the
Release page to synchronize this rule to nodes of all
With the release, Release can be viewed. No further explanation is necessary.
Then, open shell to simulate the client-side access.
$ curl -i -H 'host: rewrite-rule-test.com' http://18.104.22.168/404.html HTTP/1.1 404 Not Found Server: openresty+ Date: Mon, 21 Jan 2019 15:48:40 GMT Content-Type: text/html Content-Length: 166 Connection: keep-alive <html> <head><title>404 Not Found</title></head> <body bgcolor="white"> <center><h1>404 Not Found</h1></center> <hr><center>openresty</center> </body> </html>
So, the response body is 302 status code with a redirect to https, and other parameters did not change.