# How to redirect a specific topic to a category?

**URL:** https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949
**Category:** Support
**Created:** [June 13, 2024, 3:10pm UTC](https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949 "2024-06-13T15:10:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [June 13, 2024, 3:10pm UTC](https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949/1 "2024-06-13T15:10:12Z")

</div>

I’m a bit stuck on this one: I’d like to redirect from a specific topic to a category route, something like this:

/t/slug/123 =\> /c/slug/456

I realise the permalinks in the admin aren’t meant for existing Discourse URLs, and that this could be done with some custom code. Does anyone have an example to point me in the right direction?

Thanks!

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [June 14, 2024, 2:01pm UTC](https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949/2 "2024-06-14T14:01:28Z")

</div>

Ok, I’ve cobbled together a solution and it seems to work. Did I do this correctly, or am I doing terrible things? 🙈

```javascript
<script type="text/discourse-plugin" version="0.8"> 
    // Modify the topic route. 
    api.modifyClass('route:topic', {
    
      beforeModel( transition ) {
        var params = this.paramsFor('topic');

        // English
        if( params['id'] == 123 ) {
          this.router.transitionTo('/c/tutorials/english/29'); // Implicitly aborts the on-going transition.
        }
        
        // French
        if( params['id'] == 456 ) {
          this.router.transitionTo('/c/tutorials/french/30'); // Implicitly aborts the on-going transition.
        }
                
      }
    
    });
</script>

```

---

<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: [June 14, 2024, 3:08pm UTC](https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949/3 "2024-06-14T15:08:00Z")

</div>

Can you not do this with the permalinks?

I’ve had a quick test using the ‘external or relative url’ option (though there may be a better one), and it seemed to work okay?

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/4/7/947a8aa152f4d796e392bbad8049d2acd71afe94.png)

Just make sure to test with a user who doesn’t have the ability to see deleted topics/posts.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [June 14, 2024, 3:47pm UTC](https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949/4 "2024-06-14T15:47:58Z")

</div>

My topics aren’t deleted though, I just need them pinned as a navigation tool. I tested this and Permalinks don’t work for existing URLs, do they?

---

<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: [June 14, 2024, 4:02pm UTC](https://meta.discourse.org/t/how-to-redirect-a-specific-topic-to-a-category/311949/5 "2024-06-14T16:02:04Z")

</div>

Ah, no. Permalinks would only work if the topic is deleted, otherwise you won’t be redirected and will land on the successful url.
