# 是否能为 /t 和 /c 添加 URL 路径前缀

**URL:** https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716
**Category:** Self-hosting
**Created:** [2023年七月25日 04:13 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716 "2023-07-25T04:13:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![shibi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shibi/32/317128_2.png) [@shibi](https://meta.discourse.org/u/shibi)
#### Post date: [2023年七月25日 04:13 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/1 "2023-07-25T04:13:27Z")

</div>

更新 `/t` 和 `/c` 的默认 URL 路径前缀。基本思路是拥有一个域名和负载均衡器。

我有一个负载均衡器，其中包含两个后端集：

1. API 服务 localhost:81。
2. discourse 运行在 localhost:80。

我想设置如下路由策略：

- 如果路径以“/discourse”开头，请求将被定向到 discourse。
- 否则，请求将被定向到 API 服务。

---

<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: [2023年七月25日 05:16 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/2 "2023-07-25T05:16:14Z")

</div>

您正在讨论[子文件夹安装](https://meta.discourse.org/t/serve-discourse-from-a-subfolder-path-prefix-instead-of-a-subdomain/30507?u=supermathie)。

然而，根据主机名而不是路径来切换应用程序要简单得多。

---

<div class="post-metadata">

### Author: ![hello-smile6](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hello-smile6/32/304628_2.png) [@hello-smile6](https://meta.discourse.org/u/hello-smile6)
#### Post date: [2023年七月25日 06:00 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/3 "2023-07-25T06:00:31Z")

</div>

> [@shibi](#):
>
> 如果路径以“/discourse”开头，请求将被定向到discourse。

为什么不把API设在`/__api`或者其他地方呢？这难道不比移动Discourse更容易吗？

---

<div class="post-metadata">

### Author: ![shibi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shibi/32/317128_2.png) [@shibi](https://meta.discourse.org/u/shibi)
#### Post date: [2023年七月25日 16:36 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/4 "2023-07-25T16:36:34Z")

</div>

服务已在运行，并被其他人使用。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023年七月25日 17:33 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/5 "2023-07-25T17:33:15Z")

</div>

我回响说子域更容易，而且没有缺点。人们根本注意不到主机名，谷歌也不会。

---

<div class="post-metadata">

### Author: ![shibi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shibi/32/317128_2.png) [@shibi](https://meta.discourse.org/u/shibi)
#### Post date: [2023年七月25日 20:51 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/6 "2023-07-25T20:51:20Z")

</div>

谢谢，这正在奏效

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2023年八月24日 20:51 UTC](https://meta.discourse.org/t/possible-to-update-add-url-path-prefix-for-t-and-c/272716/7 "2023-08-24T20:51:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
