# 모든 404 페이지를 홈으로 리다이렉트하는 방법?

**URL:** https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187
**Category:** Self-hosting
**Created:** [8월 5, 2022, 5:24오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187 "2022-08-05T05:24:08Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![riteshsaini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riteshsaini/32/266453_2.png) [@riteshsaini](https://meta.discourse.org/u/riteshsaini)
#### Post date: [8월 5, 2022, 5:24오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/1 "2022-08-05T05:24:09Z")

</div>

안녕하세요,

깨진 404 페이지를 자동으로 홈 또는 다른 페이지로 리다이렉트할 수 있나요?

감사합니다

---

<div class="post-metadata">

### Author: ![riteshsaini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riteshsaini/32/266453_2.png) [@riteshsaini](https://meta.discourse.org/u/riteshsaini)
#### Post date: [8월 26, 2022, 6:41오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/2 "2022-08-26T06:41:18Z")

</div>

Discourse가 htaccess를 사용하지 않으므로 해결 방법을 어디서 찾아야 할지 확실하지 않습니다. 도움을 주시면 감사하겠습니다 🙂

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [8월 26, 2022, 6:52오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/3 "2022-08-26T06:52:39Z")

</div>

플러그인을 만들어서 그걸 달성할 수 있을지도 모르겠네요.

즉시 리다이렉트하면 혼란을 줄 수 있으니, 404 라우트를 짧은 타이머 후에 홈으로 리다이렉트하도록 변경하고 그에 맞는 메시지를 표시하는 건 어떨까요?

---

<div class="post-metadata">

### Author: ![riteshsaini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riteshsaini/32/266453_2.png) [@riteshsaini](https://meta.discourse.org/u/riteshsaini)
#### Post date: [8월 26, 2022, 6:55오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/4 "2022-08-26T06:55:38Z")

</div>

> [@merefield](#):
>
> 즉시 리디렉션하면 혼란을 줄 수 있으므로, 짧은 타이머 후 홈으로 리디렉션하도록 404 라우트를 변경하고 그에 해당하는 메시지를 표시하는 것은 어떨까요?

그렇게 하면 될 것 같지만, 어떻게 해야 하는지 모르겠습니다 😕

이 기능을 제공하는 플러그인이 있을까요?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [8월 26, 2022, 6:56오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/5 "2022-08-26T06:56:04Z")

</div>

그건 의문이다. #marketplace를 사용할 수 있다

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [8월 26, 2022, 6:56오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/6 "2022-08-26T06:56:18Z")

</div>

Apache2가 Discourse 앞에 있는 경우에도 .htaccess는 사용해서는 안 됩니다 — 그리고 실제로도 그렇지 않습니다.

Docker는 상황을 더 복잡하게 만들죠 😉 그래서 어떻게 처리해야 할지 모르겠습니다. 하지만 원한다면 Nginx(또는 다른 서버/리버스 프록시)를 Discourse 앞에 배치할 수 있습니다. 그러면 이러한 리디렉션은 꽤 단순한 작업이 될 것입니다. 다음과 같은 방식으로 처리할 수 있습니다:

[https://stackoverflow.com/questions/19487365/how-do-i-force-redirect-all-404s-or-every-page-whether-invalid-or-not-to-the](https://stackoverflow.com/questions/19487365/how-do-i-force-redirect-all-404s-or-every-page-whether-invalid-or-not-to-the)

하지만 왜 404를 프론트 페이지로 리디렉션하고 싶은 것일까요? 사용자가 무언가를 찾고 있는데 원하는 페이지나 404 대신 프론트 페이지가 표시되면 다소 혼란스럽습니다. 그리고 같은 사용자는 아마도 자신이 무언가를 잘못했거나 해당 사이트에 문제가 있다고 생각하여 다시 시도할 것입니다. 이는 전혀 필요 없는 일이며, 모든 사이트가 이상한 리디렉션 대신 404 오류를 표시해야 하는 이유이기도 합니다.

---

<div class="post-metadata">

### Author: ![riteshsaini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riteshsaini/32/266453_2.png) [@riteshsaini](https://meta.discourse.org/u/riteshsaini)
#### Post date: [8월 26, 2022, 7:06오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/7 "2022-08-26T07:06:50Z")

</div>

> [@Jagster](#):
>
> 그런데 왜 404 에러를 처음부터 홈페이지로 리다이렉트하고 싶은 건가요?

저는 WordPress 블로그를 Discourse로 이식하고 있습니다. 이제 링크 구조가 달라지기 때문에 이식 후 404 페이지가 대량으로 발생하게 됩니다. 각각을 수동으로 리다이렉트 설정할 수 없으므로, 이를 자동으로 처리할 수 있는 해결책이 필요합니다.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [8월 26, 2022, 7:14오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/8 "2022-08-26T07:14:45Z")

</div>

네, 하지만 그건 해결책이 아닙니다. 그냥 나쁜 패치일 뿐이에요. URL 구조는 여전히 깨져 있을 텐데, 그걸 숨기는 것뿐이죠. 그리고 그렇게 해서 SEO 가치를 이전할 수도 없고요. 🙂

어쨌든 — 거기서 서버를 하나 사용 중인 거라면, 그걸 활용해보는 건 어떨까요?

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [8월 26, 2022, 7:19오전 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/9 "2022-08-26T07:19:54Z")

</div>

Wordpress와 Discourse 사이트에 서로 다른 서브도메인을 사용한다면, Wordpress 서버 측에서 이를 처리할 수 있을 가능성이 높습니다.

`page_not_found.title`을 수정할 수 있습니다(기본값은 “Oops! That page doesn’t exist or is private.”). 상황을 자세히 설명할 수 있는 `page_not_found.content`와 같은 기능이 없다는 점은 다소 아쉽습니다.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8월 26, 2022, 5:11오후 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/10 "2022-08-26T17:11:07Z")

</div>

도움이 된다면 `detailed 404` 관리자 설정이 있습니다.

 ![detailed 404](https://global.discourse-cdn.com/meta/original/4X/9/7/b/97b1269e2f3fbcc753ee91158294b9b5f4aaf22b.jpeg)

---

<div class="post-metadata">

### Author: ![riteshsaini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riteshsaini/32/266453_2.png) [@riteshsaini](https://meta.discourse.org/u/riteshsaini)
#### Post date: [8월 26, 2022, 5:44오후 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/11 "2022-08-26T17:44:19Z")

</div>

제가 아는 한, 그 옵션에는 어떤 형태의 리다이렉트도 포함되지 않습니다.

---

<div class="post-metadata">

### Author: ![cocococosti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cocococosti/32/231474_2.png) [@cocococosti](https://meta.discourse.org/u/cocococosti)
#### Post date: [8월 26, 2022, 7:16오후 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/12 "2022-08-26T19:16:18Z")

</div>

> [@riteshsaini](#):
>
> 링크 구조가 다르기 때문에 마이그레이션 후 404 페이지가 대량으로 발생할 것입니다

해당 링크들이 어디를 가리키고 있는지와 관계없이… Discourse로 마이그레이션될 예정인가요? 예를 들어, 해당 링크가 블로그 포스트를 가리키고 있고 이를 토론(Topic)으로 전환하는 경우, 영구 링크(permalinks)를 생성할 수 있습니다: [Redirect old forum URLs to new Discourse URLs using permalinks](https://meta.discourse.org/t/redirecting-old-forum-urls-to-new-discourse-urls/20930)

또한 해당 URL을 다른 것으로 재매핑할 수도 있습니다. URL에 공통된 형식이 있다면 REGEX와 remap 명령을 사용하여 이를 교체할 수 있습니다:

```plaintext
remap [--global,--regex] FROM TO

```

명령어 사용 예시:

```plaintext
discourse remap --regex "\[\/?color(=[^\]]*)*]" "" # "color" bbcode 제거

```

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [8월 26, 2022, 7:30오후 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/13 "2022-08-26T19:30:42Z")

</div>

다만, 구글과 사용자 모두를 만족시키려면 WordPress 서버에서 이를 수행해야 합니다.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [11월 24, 2022, 8:58오후 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/14 "2022-11-24T20:58:38Z")

</div>

5개의 게시글이 새 주제에 분할되었습니다: [주제 삭제 후 홈 페이지로 리다이렉트하는 방법?](https://meta.discourse.org/t/how-do-i-redirect-to-homepage-after-topic-deletion/246677)

---

<div class="post-metadata">

### Author: ![nehakakar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nehakakar/32/317424_2.png) [@nehakakar](https://meta.discourse.org/u/nehakakar)
#### Post date: [8월 8, 2023, 7:59오후 UTC](https://meta.discourse.org/t/how-to-redirect-all-404-pages-to-home/235187/15 "2023-08-08T19:59:07Z")

</div>

> [@riteshsaini](#):
>
> Discourse가 htaccess를 사용하지 않기 때문에 해결책을 어디서 찾아야 할지 모르겠습니다. 도움을 주시면 감사하겠습니다.

“Customize” 기능을 사용하여 모든 깨진 404 페이지를 홈 페이지 또는 다른 페이지로 리다이렉트할 수 있습니다.  
**Customize** \> **Themes** \> **Create New Theme** 섹션으로 이동하여 테마 이름을 **404 Redirect** 등으로 지정하고, **Base Theme** 를 **Default** 로 설정하세요.  
그 다음 새 테마를 생성한 후 CSS/HTML를 편집합니다. HTML 섹션에서 리다이렉션을 처리하는 JavaScript 스니펫을 생성하세요.  
아래 코드를 붙여넣으세요.

```plaintext
<script type="text/discourse-plugin">
  api.onPageChange((url, title) => {
    // 모든 404 페이지를 홈 페이지로 리다이렉트합니다.
    if (url.includes('/404')) {
      window.location.href = '/';
    }
  });
</script>

```

필요에 따라 페이지 이름을 조정하세요. 이 [기존 URL을 새 Discourse URL로 리다이렉트하는 방법](https://meta.discourse.org/t/redirect-old-forum-urls-to-new-discourse-urls/20930)을 읽어보세요.
