# Laatste update breekt permalink voor categorieën

**URL:** https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435
**Category:** Support
**Tags:** subfolder
**Created:** [1 maart 2024 om 10:03 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435 "2024-03-01T10:03:31Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [1 maart 2024 om 10:03 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/1 "2024-03-01T10:03:31Z")

</div>

With the last update the permalink to category is broken, permalinks for topics are working fine.  
For example: category/11562 redirects to c/11562 which is incorrect, the redirect which is correctly set as destination should be c/general/4 or c/4  
Could anybody help with this problem?

---

<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: [1 maart 2024 om 10:20 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/2 "2024-03-01T10:20:41Z")

</div>

You created a permalink for category/11562 that used to redirect to general, but now it’s broken?

---

<div class="post-metadata">

### Author: ![anon36555649](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon36555649](https://meta.discourse.org/u/anon36555649)
#### Post date: [1 maart 2024 om 12:49 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/3 "2024-03-01T12:49:44Z")

</div>

Which update branch is that from?

---

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [1 maart 2024 om 13:00 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/4 "2024-03-01T13:00:20Z")

</div>

Correct, it used to work fine. Then, I updated to:

```
<meta name="generator" content="Discourse 3.3.0.beta1-dev - https://github.com/discourse/discourse version 0bb492c6b6b79389a12b277b9d25b99e75f2625d">

```

Completly clean the DB to re-import some other forum data from scratch, and now is not working.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [1 maart 2024 om 13:08 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/5 "2024-03-01T13:08:36Z")

</div>

> [@pama](#):
>
> Completly clean the DB to re-import some other forum data from scratch

I think this is the problem, because I cannot repro this on tests passed as of this morning.

Can you see if the permalink is still there in your database and if it still points to the right place?

---

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [1 maart 2024 om 13:19 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/6 "2024-03-01T13:19:03Z")

</div>

I added the permalinks again with the new import, it is done by the import script. But I also tried to add by hand using the web. Please, find attached a screenshot of the web and the results from DB. Maybe I’m missing something:

 ![Screenshot 2024-03-01 at 2.12.45 PM](https://global.discourse-cdn.com/meta/original/4X/4/8/8/48867300ba6ea027a9232a3707f682f3c9a9d840.png)

---

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [1 maart 2024 om 13:19 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/7 "2024-03-01T13:19:35Z")

</div>

Sorry, only one screenshot per post was allowed

 ![Screenshot 2024-03-01 at 2.16.33 PM](https://global.discourse-cdn.com/meta/original/4X/9/8/f/98f108d353c3d00f9809e514db353867ed5ae026.png)

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [1 maart 2024 om 13:26 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/8 "2024-03-01T13:26:01Z")

</div>

Your permalink is not at `/category/11562` but at `/forum/category/11562`.

My quick guess is that you lost your permalink normalizations along the way.

---

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [1 maart 2024 om 14:24 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/9 "2024-03-01T14:24:41Z")

</div>

I do not understand if I check the response to `https://preview.vaadin.com/forum/category/11562`

I receive a 302 with Location:  
`https://preview.vaadin.com/forum/c/11562`

Whereas for topics for example:  
`https://preview.vaadin.com/forum/thread/851770`

I receive a 301 with Location:  
`https://preview.vaadin.com/forum/t/tabsheet-tabs-not-displaying-properly-in-ie8-after-upgrade-to-6-7-1/173931`

I expect Discourse to manage both equally, and as you can see both retain the segment /forum/

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [1 maart 2024 om 14:55 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/10 "2024-03-01T14:55:01Z")

</div>

> [@pama](#):
>
> [https://preview.vaadin.com/forum](https://preview.vaadin.com/forum)

So you didn’t mention the fact that your entire forum is a subfolder install.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [1 maart 2024 om 15:17 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/11 "2024-03-01T15:17:11Z")

</div>

So I dug in a bit deeper and I don’t understand how this could have ever worked, since `category/` will always trigger the categories#redirect route, and this did not recently change.

```
get "category/*path" => "categories#redirect"

```

EDIT the post below shows it did use to work

---

<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: [1 maart 2024 om 15:18 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/12 "2024-03-01T15:18:09Z")

</div>

> [@RGJ](#):
>
> So you didn’t mention the fact that your entire forum is a subfolder install.

Yeah. I can’t begin to wrap my head around how permalinks and permalink\_normalizations would work in a subfolder install.

> [@pama](#):
>
> Completly clean the DB to re-import some other forum data from scratch, and now is not working.

And it’s always been a subfolder install?

And nothing else changed when you re-ran the import script?

It seems most likely that something is different in your script.

Wait. `https://meta.discourse.org/category/67` redirects to [Announcements - Discourse Meta](https://meta.discourse.org/c/announcements/67), so . . . no, but there’s a spec that shows permalinks override that `/category` redirect and it’s 4-5 years old.

> <https://github.com/discourse/discourse/blob/main/spec/requests/categories_controller_spec.rb#L40-L52>

So I think I would create some category redirects by hand next to figure out what is going on (like `/category/mycategory` or other thing that doesn’t even have numbers in it)

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [1 maart 2024 om 15:19 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/13 "2024-03-01T15:19:44Z")

</div>

Good find @pfaffman , that test means that it should have worked indeed.

---

<div class="post-metadata">

### Author: ![anon36555649](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon36555649](https://meta.discourse.org/u/anon36555649)
#### Post date: [1 maart 2024 om 15:46 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/14 "2024-03-01T15:46:17Z")

</div>

> [@RGJ](#):
>
> entire forum is a subfolder install

Wow, didn’t even know that was possible!

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [1 maart 2024 om 15:47 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/15 "2024-03-01T15:47:08Z")

</div>

Yes, it’s pretty neat, see [Serve Discourse from a subfolder (path prefix) instead of a subdomain](https://meta.discourse.org/t/serve-discourse-from-a-subfolder-path-prefix-instead-of-a-subdomain/30507)

---

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [4 maart 2024 om 09:22 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/16 "2024-03-04T09:22:41Z")

</div>

Thanks for all your answers!

Interestingly, we found out that permalinks for categories work from subfolder only if there is no path named `/category/` in the origin url. As @pfaffman mention in his answer. For example, /forum/category\_foo/123 redirets correctly to the destination general category.  
Discourse captures `/category/` and overrides to `/c/`  
Consequently, this can be solved really easy:  
add a permalink from `/c/11562` which is the redirect from old `category/11562` to category General `/c/4`.

And you were right, the first installation was without subfolder, but the 2nd had the subfolder, this is the 3rd. And we tested, and I believe it was working the first 2 times. The only thing that changed between 2nd and 3rd is that we did not clean the db between 1st and 2nd, and for the 3rd it was a clean install with a new db outside the docker (beside upgrade to Discourse v3). So I suspect something has changed in Discourse v3 beta. Otherwise, why it has ever worked, even without subfolder?

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [4 maart 2024 om 10:27 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/17 "2024-03-04T10:27:30Z")

</div>

> [@pama](#):
>
> why it has ever worked, even without subfolder

Here is your answer

> [@pama](#):
>
> first installation was without subfolder, but the 2nd had the subfolder (…) we did not clean the db between 1st and 2nd

---

<div class="post-metadata">

### Author: ![pama](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@pama](https://meta.discourse.org/u/pama)
#### Post date: [4 maart 2024 om 10:57 UTC](https://meta.discourse.org/t/last-update-breaks-permalink-for-categories/297435/18 "2024-03-04T10:57:54Z")

</div>

If I understood correct, what you mean is that Discourse only applies the redirect from /category/ to /c/ if there is a segment in the route.

Nonetheless, if I use your forum as an example: `https://meta.discourse.org/` and put `https://meta.discourse.org/category/1` I get redirected to `https://meta.discourse.org/c/bug/1`

Which is the same we experience with our installation, it would be impossible for your site too to get redirected from /category/#old\_number to /c/#real\_category you would always end up in /c/#old\_number
