官方文档:Single Redirects — Example rules · Cloudflare Rules docs
网上很多资料要么过旧要么根本不行。我来个实操成功的。
免费帐户最多 10 条重定向规则。
先决条件
- 重定向方向:
aaa.old.com
→bbb.new.com
。 old.com
托管在 Cloudflare 上,也就是域名解析使用 Cloudflare。new.com
可以不在 Cloudflare 上解析,属于哪个域名服务商都行。
如果是其他情况,比如
www.old.com
→old.com
aaa.old.com
→bbb.old.com
aaa.old.com
→aaa.new.com
old.com
→new.com
按照方向对应就可以了。注意
一定是要托管在 CF 上的。aaa.old.com
域名解析
做一个指向 bbb.new.com
的 cname 解析,红圈的代理可开可不开(四级及以上域名不能开,因为 CF 免费证书没有覆盖到,开了浏览器访问会报错):

添加规则


- 选择“自定义”
- 选择“主机名”
- 填入旧域名
- 选择“动态”
- 填入表达式
concat("https://bbb.new.com", http.request.uri.path)
,替换为自己的新域名。根据自己服务器有没有设置 SSL 来决定是 http 还是 https。 - 选择重定向代码,永久的是 301 308,临时的是 302 307。
- 选择“保留”。
- 保存即可生效。
然后可以到这里去查询重定向是否生效:https://www.dute.org/httpstatus
Comments 4 条评论
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
不错,学习了,多谢分享!
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
如果是从abc.com跳转到bac.com/abc.html这种指定页面可用吗
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
@770603367 应该是可以的,在那个concat表达式把逗号后面那个替换成abc.html
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 367
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
Warning: Trying to access array offset on value of type null in /www/wwwroot/wordpress/wp-content/themes/Sakurairo-main/functions.php on line 368
不开代理,cf怎么帮你重定向