# Best practices for URL forwarding/rewriting from a previous (non-Discourse) system

**URL:** https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657
**Category:** Self-hosting
**Tags:** hosting
**Created:** [10월 29, 2014, 10:30오후 UTC](https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657 "2014-10-29T22:30:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![evanw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evanw/32/104827_2.png) [@evanw](https://meta.discourse.org/u/evanw)
#### Post date: [10월 29, 2014, 10:30오후 UTC](https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657/1 "2014-10-29T22:30:13Z")

</div>

I recently migrated a Vanilla Forums-based discussion board to Discourse (which I’m super excited about), and I’m looking for input on best practices when forwarding or redirecting URLs from the old platform to the new platform.

I’m not expecting to achieve a 1-to-1 mapping between the two systems, but I’d like to try to find a happy medium that gets users to the new forums as best as possible, while behaving nicely with search engines.

No need to provide technical specifics (but if you do, I’m using nginx); I’m more curious about what is the “most correct” way to handle this scenario with regards to good user experience and HTTP redirection practices.

Thanks for any feedback!

---

<div class="post-metadata">

### Author: ![kayone](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayone/32/107166_2.png) [@kayone](https://meta.discourse.org/u/kayone)
#### Post date: [10월 30, 2014, 5:15오전 UTC](https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657/2 "2014-10-30T05:15:17Z")

</div>

For your main question, if you want to behave according to HTTP spec, for any url that you can map 1-to-1 you should redirect using status code of `301 Moved Permanently`.

For other urls, if you have the option of parsing the original url, generating and redirecting the user to a search page that has list of relevant pages you should use `300 Multiple Choices`. (but I would say you are also safe to just 301 here).

Another important thing to do specially regarding search engines,

make sure you have registered for webmaster tools for the ones you care about, after you have your redirect setup, remove the old site from index and force a crawl on your new site. some even give you the option of changing the your address

> **[Change of Address tool - Search Console Help](https://support.google.com/webmasters/answer/9370220?hl=en&visit_id=639158887710894263-3039050282&rd=1)**
>
> Move your site from one domain to anotherAbout this tool Use the Change of Address tool when you move your website from one domain or subdomain to another: for instance, from example.c

another option that might take some effort but would prevent almost any broken links is to create a mapping db during migration. the db would map from vanilla thread ID to the new discourse thread ID. point your old domain to a simple server that dynamically generates the new url and does a 301 to it.

\*Pro Tip: the slugs in the urls don’t actually mean anything all discourse cares about it the ID at the end.  
eg. you can point to this thread using [Best practices for URL forwarding/rewriting from a previous (non-Discourse) system](https://meta.discourse.org/t/21657)

hope it helps.

---

<div class="post-metadata">

### Author: ![evanw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evanw/32/104827_2.png) [@evanw](https://meta.discourse.org/u/evanw)
#### Post date: [10월 30, 2014, 4:21오후 UTC](https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657/3 "2014-10-30T16:21:54Z")

</div>

Thank you so much for the comprehensive and thorough reply, this is very helpful!

My only remaining question is: What is the best location within Discourse to link to as landing page for redirects? Obviously redirecting requests for the old main forum page would just go to the new main forum page, but for specific topics themselves (not being directly mapped), the best I’ve found so far is Discourse’s “404-ish” page, like this: [https://meta.discourse.org/t/not-a-real-topic-i-hope](https://meta.discourse.org/t/not-a-real-topic-i-hope)

Otherwise, I haven’t yet been able to find a way to link to any search result page or similar.

---

<div class="post-metadata">

### Author: ![kayone](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayone/32/107166_2.png) [@kayone](https://meta.discourse.org/u/kayone)
#### Post date: [10월 30, 2014, 4:39오후 UTC](https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657/4 "2014-10-30T16:39:00Z")

</div>

It seems like there is no dedicated search page, so the 404 page might be your best bet besides doing the mapping.

> [@Permalink to Discourse search](https://meta.discourse.org/t/permalink-to-discourse-search/18818/7):
>
> We don’t have a dedicated search page, it’s on our roadmap possibly in the next few months

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [10월 8, 2015, 3:07오전 UTC](https://meta.discourse.org/t/best-practices-for-url-forwarding-rewriting-from-a-previous-non-discourse-system/21657/5 "2015-10-08T03:07:06Z")

</div>

> [@kayone](#):
>
> It seems like there is no dedicated search page

In the meantime a search page has been implemented:

[https://meta.discourse.org/search?q=thread+title](https://meta.discourse.org/search?q=thread+title)

I use this method to redirect from MyBB to Discourse, via a banner in the `showthread` template:

```plaintext
<div style="background: yellow; padding: 3em; color: red; font-weight: bold">
 This thread was migrated to
     <a href="http://newdomain.com/search?q={$thread['subject']}">the new forum</a>.
 Please <a href="http://newdomain.com/t/welcome-to-discourse/8">transfer your username</a>
     (if you haven't done so already) then reply there.
</div>

```

> [@kayone](#):
>
> another option that might take some effort but would prevent almost any broken links is to create a mapping db during migration. the db would map from vanilla thread ID to the new discourse thread ID.

This is a very clever idea. To create such a mapping between post IDs, you only need to add [one line](https://github.com/dandv/discourse-post-process#fixing-quotes) of Ruby code to the MyBB importer.

You now have two options:

1. Use a web server, e.g. nginx, to do the redirects. Then you need to format the output into something ngix will understand:

2. Keep the old forum (or a portion of it) running. It will supply the thread/post ID as a (PHP) variable, so you’ll be able to redirect even threads that don’t have an ID in their URL. What you minimalistically need to keep running is a mapping between the thread title and the thread id, so you can map from that to the Discourse `topic_id` and `post_num`.

See also the redirecting howto. [Post #21](https://meta.discourse.org/t/redirecting-old-forum-urls-to-new-discourse-urls/20930/21) is my nginx map method.

> [@Redirect old forum URLs to new Discourse URLs using permalinks](https://meta.discourse.org/t/redirecting-old-forum-urls-to-new-discourse-urls/20930):
>
> Redirecting Old Forum URLs to New Discourse URLs using permalinks If you’ve moved from other forum software to Discourse using [one of our import scripts](https://github.com/discourse/discourse/tree/main/script/import_scripts), then you probably want all your hard-earned Google search results to continue pointing to the same content. Discourse has a built-in way to handle this for you as an alternative to writing nginx rules, using the permalinks lookup table. The permalinks table allows you to set two things: a url to match, and what that url should show. There a…
