配置 Vercel.json 以支持服务器级别的重定向

正式开始 官方文档: Redirects 在你的仓库根目录创建 vercel.json 写入重定向规则 source 为要重定向的路径,destination 为重定向到的路径/URL,permanent 为一个可选的布尔值,用于在永久重定向和临时重定向之间切换(默认为 true)。当 true 时,状态代码为 308。当 false 时,状态代码为 307。 { "redirects": [ { "source": "/ak", "destination": "https://akile.io/register?aff_code=503fe5ea-e7c5-4d68-ae05-6de99513680e", "permanent": false }, { "source": "/kook", "destination": "https://kook.vip/K29zpT", "permanent": false }, { "source": "/long", "destination": "https://iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.in/", "permanent": false }, { "source": "/mly", "destination": "https://muleyun.com/aff/GOTRJLPN", "permanent": false }, { "source": "/tg", "destination": "https://t.me/+_07DERp7k1ljYTc1", "permanent": false }, { "source": "/tit", "destination": "/posts/pin/", "permanent": false }, { "source": "/tly", "destination": "https://tianlicloud.cn/aff/HNNCFKGP", "permanent": false }, { "source": "/wly", "destination": "https://wl.awcmam.com/#/register?code=FNQwOQBM", "permanent": false }, { "source": "/yyb", "destination": "https://www.rainyun.com/acofork_?s=bilibili", "permanent": false } ] }

September 1, 2025 · 1 min · 94 words

利用Astrov3的原生重定向来实现各种各样的高级重定向!

正式开始 Astro v3 正式支持了原生的重定向 路由 | 文档 - Astro 文档 仅需在 astro.config.mjs 中添加如下代码,示例代码将 /tit 的请求 302 重定向到 /posts/pin 。可以配置多行重定向规则 import { defineConfig } from "astro/config"; export default defineConfig({ redirects: { "/tit": { destination: "/posts/pin/", status: 302, }, } }); 有的小伙伴就会问了,如果我的Astro输出模式为SSG?那Astro的重定向是不是不支持 location 重定向?仅支持 HTML 重定向? 的确,在不对构建服务商进行额外配置的情况下,Astro会使用兼容模式,创建 HTML 重定向,你可以尝试安装适配器来支持重定向,但需要注意 并不是所有适配器都会透传Astro中设置的重定向规则 ,始终建议使用您构建服务商提供的重定向服务,参见: 配置 Vercel.json 以支持服务器级别的重定向。如配置 vercel.json 。关于 Astro 适配器的更多信息,参见 配置参考 | Docs

September 1, 2025 · 1 min · 59 words