# Missing Pages: Redirect or 404? | Creght AI Documentation

> When a visitor opens a URL that doesn't exist, you have two options: redirect them to another page , or serve a “page not found” (404) page .…

[![Creght](https://ugc.talizen.com/_assets/site/2061660904709165056/1780797461299__creght_logo.png)Help Center](/help)

[Changelog](/blogs)

[AI](/docs/ai/quick-create-first-website) [Visual](/docs/get-start)

Getting Started

- [Create Your First Website in 5 Minutes](/docs/ai/quick-create-first-website)
- [AI Website Creation Guide](/docs/ai/ai-create-website-guide)
- [Direct Editing: Update Content Without Credits](/docs/ai/ai-edit-content-guide)
- [Use Pick to Bring a Section from Another Template into Your Site](/docs/ai/pick-element-in-tpl)
- [Prompt Library](/docs/ai/prompt-lib)
- [AI Credits Guide](/docs/ai/ai-credits-guide)
- [Creght Skill](/docs/ai/creght-skill)

Backend

- [Add Login, Bookings, Private Pages, and More to Your Website](/docs/ai/backend-database-guide)
- [Configure OAuth Login: Google and GitHub](/docs/ai/backend-auth-guide)

Site Setting

- [Multilingual Website Setup Guide](/docs/ai/localization)
- [Domain Binding Guide](/docs/ai/custom-domain)
- [Alibaba Cloud Domain Purchase Guide (Beginner Version)](/docs/ai/aliyun-domain-registration-guide)
- [Redirect Setup Guide](/docs/ai/redirects)
- [Missing Pages: Redirect or 404?](/docs/ai/redirect-or-404)
- [Meta Pixel Integration Guide](/docs/ai/facebook-meta-pixel)

Advanced Usage

- [Configure Different Default Languages for Different Domains](/docs/ai/domain-locale-routing)

Site Setting/

# Missing Pages: Redirect or 404?

When a visitor opens a URL that doesn't exist, you have two options: **redirect them to another page**, or **serve a “page not found” (404) page**. Both avoid showing a raw error, but they mean very different things—and using the wrong one hurts your SEO and user experience.

This guide helps you tell them apart and shows the right way to handle each in Creght.

## The Short Answer

- **A specific old URL has moved to a new URL** → use a **redirect**.

- **The URL should never have existed (typos, deleted pages, guessed links)** → return a **404** with a friendly not-found page.

- **Do NOT** redirect every unknown URL to your homepage—search engines explicitly advise against it.


## Redirect vs. 404: What's the Difference?

|  | Redirect | 404 Page |
| --- | --- | --- |
| Address bar URL | **Changes** (moves to new address) | **Stays** (remains on the original URL) |
| HTTP status code | 301 / 308 (permanent), 302 / 307 (temporary) | 404 |
| Meaning | “This content moved—go there instead” | “This content doesn't exist” |
| How search engines read it | Transfers ranking signals to the new URL | Knows the URL is invalid; drops it from the index |
| When to use | Known, one-to-one URL migrations | Any unknown / removed URL |

The key idea: **a redirect is a “we moved” notice, a 404 is “no such page.”** A random non-existent URL hasn't moved anywhere, so it shouldn't be redirected—it should honestly tell search engines and users that there's nothing here.

## Three Common Scenarios

### Scenario 1: Give visitors a friendly “not found” page

A visitor mistypes a URL or clicks a link to a page you've deleted. You want a page that isn't jarring—ideally with a link back home, a search box, or popular content.

**Do this: build a custom 404 page.** The URL stays the same, the status code is 404, and you fully control the page design. This is the right choice in the vast majority of cases.

### Scenario 2: An old URL has moved to a new one

For example, you renamed `/old-blog/hello` to `/posts/hello`, and the old link is still referenced elsewhere, bookmarked, or indexed.

**Do this: configure a redirect rule** using a permanent (308) redirect from the old URL to the new one. Visitors and search engines are smoothly carried to the new address, and the old URL's accumulated SEO value transfers over.

### Scenario 3: Send every unknown URL to the homepage

This looks “tidy,” but it's **strongly discouraged**.

- For search engines: Google treats “content doesn't exist but returns 200 or redirects to the homepage” as a **soft 404**, which lowers your site quality signals. Google officially recommends returning a real 404 for non-existent pages.

- For users: visitors end up on the homepage unexpectedly, confused, and still can't find what they were looking for.


**The right approach:** return a 404, and put a prominent “back to home” button on the 404 page. This satisfies search engines and respects your users.

## How to Do It in Creght

### 1\. Custom 404 page: create `page/404.tsx`

Add a page named `404` in your pages directory ( `page/404.tsx`). From then on, any URL that doesn't match a route automatically renders this page and returns a 404 status code, keeping the visitor's original URL in the address bar.

```
// page/404.tsx
export default function NotFound() {
  return (
    <main style={{ textAlign: 'center', padding: '80px 20px' }}>
      <h1>404</h1>
      <p>Sorry, the page you're looking for doesn't exist.</p>
      <a href="/">Back to home</a>
    </main>
  )
}
```

Likewise, you can create `page/500.tsx` to customize the page shown when a server error occurs.

> Tip: a 404 page works like any other page—you can use components, styling, and `getServerSideProps`, e.g. to show recommended articles or a site search box.

### 2\. Redirects: define `redirects` in `talizen.config.ts`

For known URL migrations, configure redirect rules in `talizen.config.ts` at your site root:

```
// talizen.config.ts
export default {
  redirects: [
    // Exact match: 308 permanent redirect
    { source: '/old-page', destination: '/new-page', permanent: true },
    // Wildcard: migrate everything under /blog to /posts (307 temporary)
    { source: '/blog/*', destination: '/posts/*', permanent: false },
  ],
}
```

- `permanent: true` returns **308 (permanent)**—use it when content has truly moved for good and you want to transfer SEO value.

- `permanent: false` returns **307 (temporary)**—use it for temporary redirects.

- `source` supports exact matches and a trailing `/*` wildcard (the matched segments are back-filled into the `*` in `destination`).


Redirect rules take priority over page matching: a matched URL redirects immediately without rendering a page, so it never triggers a 404.

## Quick Decision Guide

- Did this URL **once have content that has now moved**? → **Redirect** ( `redirects` in `talizen.config.ts`, use 308 for permanent).

- Should this URL **never have existed**? → **404** (custom `page/404.tsx` with a link back home).

- Not sure? → Default to **404**. It's the safest, most SEO-friendly fallback.


On this page

- [The Short Answer](#the-short-answer)
- [Redirect vs. 404: What's the Difference?](#redirect-vs-404-what-s-the-difference)
- [Three Common Scenarios](#three-common-scenarios)
- [Scenario 1: Give visitors a friendly “not found” page](#scenario-1-give-visitors-a-friendly-not-found-page)
- [Scenario 2: An old URL has moved to a new one](#scenario-2-an-old-url-has-moved-to-a-new-one)
- [Scenario 3: Send every unknown URL to the homepage](#scenario-3-send-every-unknown-url-to-the-homepage)
- [How to Do It in Creght](#how-to-do-it-in-creght)
- [1\. Custom 404 page: create page/404.tsx](#1-custom-404-page-create-page-404-tsx)
- [2\. Redirects: define redirects in talizen.config.ts](#2-redirects-define-redirects-in-talizen-config-ts)
- [Quick Decision Guide](#quick-decision-guide)

![Creght](https://ugc.talizen.com/_assets/site/2061660904709165056/1780797461299__creght_logo.png)

This website is built with [Creght](/)

[Discord](https://discord.gg/Qvq2nmZNnb)

## Links

- [Pricing](/price)
- [Help Center](/help)
- [Contact Us](/contact)
- [Blog](/blogs)
- [Refund Policy](/tuikuan)

## Resources

- [All Resources](/resources)
- [Templates](/templates)
- [Components](https://creghtlib.site.creght.com)
- [Animations](/effects)
- [Figma to Creght](/figma2creght)
- [API for AI](/api)

## Terms

- [Terms of Service](/legal/terms)
- [Privacy Policy](/legal/privacy)
- [Acceptable Use Policy](/legal/acceptable-use)

## Social Media

- [Twitter](https://twitter.com)
- [Facebook](https://www.facebook.com)
- [LinkedIn](https://www.linkedin.com)

[蜀ICP备2023038192号-2](https://beian.miit.gov.cn)
