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

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!

1 Like

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
https://support.google.com/webmasters/answer/83106?hl=en

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 https://meta.discourse.org/t/21657

hope it helps.

5 Likes

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

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

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

In the meantime a search page has been implemented:

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:

<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>

This is a very clever idea. To create such a mapping between post IDs, you only need to add one line 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:

    map $uri $uri_new {
    default>$uri;
    
    /...?post=8 /t/54/1;  # old post_id -> /t/topic_id/post_num
    /...?post=157 /t/73/10;
    ...
    }
    
    # do the maping - http://wiki.nginx.org/HttpMapModule
    rewrite ^ $uri_new permanent;
    

    This is what I’ve done for my MyBB forum.

  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 is my nginx map method.

2 Likes