当您需要将请求URI中的HTTP重定向为HTTPS,或您访问的URI与源站URI不匹配时,需要将URI修改为与源站匹配的URI。您修改URI中指定内容时,需要配置重写规则,规则匹配后会302跳转到目标URI。您还可以根据实际需求配置多条重写匹配规则。本文为您介绍配置重写规则的操作方法。
背景信息
如果您需要对请求URI进行修改,请添加重写功能。例如您的某些用户或客户端仍然使用HTTP协议访问http://example.com
,您可以通过该功能配置,所有http://example.com
请求都重定向到https://example.com
。
操作步骤
操作样例
样例 | 待重写URI | 目标URI | 执行规则 | 结果说明 |
---|---|---|---|---|
样例一 | /hello | /index.html | Redirect | 客户端请求http://example.com/hello ,SCDN节点将返回302让客户端重新请求http://example.com/index.html 的内容。
|
样例二 | ^/hello$ | /index.html | Break | 客户端请求http://example.com/hello ,SCDN节点将返回http://example.com/index.html 的内容,且该请求不再继续匹配其余的重写规则。
|
样例三 | ^/$ | /index.html | Redirect | 客户端请求http://example.com ,SCDN节点将返回302让客户端重新请求http://example.com/index.html 的内容。
|
样例四 | /hello | /hello/index.html | Redirect | 客户端请求http://example.com/hello ,SCDN节点将返回302让客户端重新请求http://example.com/hello/index.html 的内容。
|