Skip to content

Commit

Permalink
new file: vercel/add-web-server-layer-redirects.md
Browse files Browse the repository at this point in the history
  • Loading branch information
byt3h3ad committed Jun 17, 2024
1 parent 554d88d commit 5a5c2a7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions vercel/add-web-server-layer-redirects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Add Web Server Layer Redirects

People create links and bookmark URLs. Content, for a variety of reasons, has
to move from one place to another. For everyone's sake, you don't want to break
the URLs that people have come to rely on.

You need to setup some
[redirects](https://vercel.com/docs/configuration#project/redirects).

Though a [Next.js](https://nextjs.org/) app is just frontend code, when
distributed through [Vercel](https://vercel.com/), you can include some
configuration of the web server layer.

Add the `vercel.json` file to the top-level directory of your Next.js project
and then include any needed redirect rules.

```json
{
"redirects": [
{
"source": "blog/old-blog-post-name",
"destination": "blog/new-blog-post-name"
},
{
"source": "/store",
"destination": "store.example.com"
}
]
}
```

In the first rule, one path is redirected to another for the same domain. In
the second rule, the path is redirected to an external URL.

By default, these redirects get a [308 status
code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308).

0 comments on commit 5a5c2a7

Please sign in to comment.