{"slug":"cfpage-redirect","title":"利用Cloudflare Page提供的重定向功能实现无损耗、不限数量的静态重定向！","description":"Cloudflare的重定向规则非常强大，但是如果直接使用重定向规则创建批量重定向会消耗很多的配额","coverImage":"https://b.acofork.com/img/cfpage-redirect-530d7a11-c9ea-45ed-905a-1e3965f3e3b3.webp","coverWidth":461,"coverHeight":333,"date":"2025-07-12","tags":["网络"],"pinned":false,"wordCount":140,"html":"<h2 id=\"快速上手\">快速上手！</h2><p>直接 Fork我的 <a href=\"https://github.com/afoim/Redirect_Group\" target=\"_blank\" rel=\"noopener noreferrer\">仓库</a> 。</p>\n<p>接着将该仓库连接到Cloudflare部署Worker或Page，然后绑定你的域名</p>\n<p><img src=\"https://b.acofork.com/img/cfpage-redirect-0c99399a-5d25-4372-9f9b-79767c32d150.webp\" alt=\"\" width=\"1141\" height=\"496\" loading=\"eager\" decoding=\"async\" /></p>\n<p>接着更改 <code>_redirects</code> 内的文件</p>\n<p><img src=\"https://b.acofork.com/img/cfpage-redirect-f9476b1d-b047-441b-a742-58124032a91b.webp\" alt=\"\" width=\"1000\" height=\"411\" loading=\"lazy\" decoding=\"async\" /></p>\n<p>例如： </p>\n<div class=\"markdown-code\" data-language=\"bash\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>bash</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-bash\">/ https://www.afo.im/ 301\n/test/* https://test.test/test/:splat 302</code></pre></div><p>则意味着</p>\n<p>访问 <code>/</code> 301 永久重定向到 <code>https://www.afo.im/</code> </p>\n<p><img src=\"https://b.acofork.com/img/cfpage-redirect-3f49855c-6835-423d-805c-4758f232d136.webp\" alt=\"\" width=\"387\" height=\"308\" loading=\"lazy\" decoding=\"async\" /></p>\n<p>访问 <code>/test/*</code> 302 临时重定向到 <code>https://test.test/test/*</code></p>\n<p><img src=\"https://b.acofork.com/img/cfpage-redirect-f018f75a-83ae-435e-9fce-d81d331f6d2f.webp\" alt=\"\" width=\"461\" height=\"308\" loading=\"lazy\" decoding=\"async\" /></p>\n<p>已经非常强大了。而且不占用重定向规则配额也不耗费Worker请求数！</p>\n","toc":[{"id":"快速上手","text":"快速上手！","depth":2}]}