mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 09:03:18 +08:00
posts: 更新重定向文档并添加vercel重定向指南
更新Astro重定向文档中的链接指向新创建的vercel重定向指南,并添加详细的vercel.json配置说明和示例
This commit is contained in:
BIN
src/content/assets/images/2025-09-02-06-34-54-image.png
Normal file
BIN
src/content/assets/images/2025-09-02-06-34-54-image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
@@ -30,4 +30,4 @@ export default defineConfig({
|
||||
|
||||
有的小伙伴就会问了,如果我的Astro输出模式为SSG?那Astro的重定向是不是不支持 `location` 重定向?仅支持 `HTML` 重定向?
|
||||
|
||||
的确,在不对构建服务商进行额外配置的情况下,Astro会使用兼容模式,创建 `HTML` 重定向,你可以尝试安装适配器来支持重定向,但需要注意 **并不是所有适配器都会透传Astro中设置的重定向规则** ,始终建议使用您构建服务商提供的重定向服务,如配置 `vercel.json` 。关于 Astro 适配器的更多信息,参见 [配置参考 | Docs](https://docs.astro.build/zh-cn/reference/configuration-reference/#adapter)
|
||||
的确,在不对构建服务商进行额外配置的情况下,Astro会使用兼容模式,创建 `HTML` 重定向,你可以尝试安装适配器来支持重定向,但需要注意 **并不是所有适配器都会透传Astro中设置的重定向规则** ,始终建议使用您构建服务商提供的重定向服务,参见: [配置 Vercel.json 以支持服务器级别的重定向](/posts/redirects/)。如配置 `vercel.json` 。关于 Astro 适配器的更多信息,参见 [配置参考 | Docs](https://docs.astro.build/zh-cn/reference/configuration-reference/#adapter)
|
||||
|
||||
70
src/content/posts/vercel-redirects.md
Normal file
70
src/content/posts/vercel-redirects.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: 配置 Vercel.json 以支持服务器级别的重定向
|
||||
published: 2025-09-02T06:33:27
|
||||
description: '如果你的站点(无论静态/动态)正在使用Vercel,则配置重定向是一件非常轻松的事情'
|
||||
image: '../assets/images/2025-09-02-06-34-54-image.png'
|
||||
tags: [Vercel, 重定向]
|
||||
|
||||
draft: false
|
||||
lang: ''
|
||||
---
|
||||
|
||||
# 正式开始
|
||||
|
||||
> 官方文档: [Redirects](https://vercel.com/docs/redirects)
|
||||
|
||||
在你的仓库根目录创建 `vercel.json` 写入重定向规则
|
||||
|
||||
`source` 为要重定向的路径,`destination` 为重定向到的路径/URL,`permanent` 为一个可选的布尔值,用于在永久重定向和临时重定向之间切换(默认为 `true`)。当 `true` 时,状态代码为 [308](https://developer.mozilla.org/docs/Web/HTTP/Status/308)。当 `false` 时,状态代码为 [307](https://developer.mozilla.org/docs/Web/HTTP/Status/307)。
|
||||
|
||||
```json
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user