Redirection Plugin

Plugin Requests
  • Hi Everyone !
    I was looking for a plugin to handle the 404 errors 👩‍🚀 inside NodeBB.
    Instead of redirecting directly to the custom 404 page, i want to be able to try a specific set of rules (using regular expressions) to see if i can find a redirection to a better resource.
    I need this plugin because we migrated an old nukephp forum, and some of the ancien posts didn't make it through because they were obsolete in the new context.

    I searched through the Install Plugin page, but didn't find anything that could fit my needs.
    Does anyone know of a plugin that would be close enough, or what could be the best starting point to write mine ?


  • I am not sure if one exists, but you can use the hook action:meta.override404 to add your custom logic. Keep in mind this overrides the entire core 404 code, so you might have to copy some of the code from core to handle the default routes.

  • @zipang The best way to handle old redirects would be to utilise a reverse proxy to handle the redirection. That reduces the strain on NodeBB (as you're not accessing NodeBB, being redirected, and then accessing NodeBB again).

    On nginx, we recommend using an nginx map to route resources to the new URLs.

    Keep in mind if you're redirecting specific topics/posts to their NodeBB equivalents, you'll need to maintain an index of the old pids/tids corresponding to their new ones.

  • Thnxx @julian ! and congrats to all the team for all this awesome work on nodebb !! 🙂

    I'm a little bit puzzled by your answer, and maybe i'm not getting it right.
    So, indulge me with a more thorough explanation of my use case :

    I've allready have put nginx in front of nodebb with this classic configuration :
    It handles all the static assets and then call nodebb for the dynamics parts.

    So, now, i just have to deal with something like 100-500 old topics (that have been correctly rewritten to our new nodebb urls with a different set of nginx redirect rules) but they are not here anymore, and i want to find redirections to new topics for the part of them that are the most requested..

    It's really an SEO thing : we don't want to loose the good rankings the old forum had.
    These old topics are have been indexed by google or some old facebook post and they are really frequently requested ...

    But i don't see the interest to put these (hundreds?) of special redirections rules inside nginx that handles allready every single request to nodebb ?? That would put a serious (indue) work on him on every request ?

    I really dream of a core nodebb plugin that could handle all these 404 inside nodebb when everything else have been tried (so that it would be a very scarce event).

    Like i've said before : it's really a use-case of dealing with a post-migration trauma because these 404 will for sure disappear with time and the new google indexations.. but we want to address them now so that we dont loose ranks...
    My boss is really watching the 404 pages as they happen, and he could deal with them in the back-office, but for sure he doesn't want to edit the nginx configuration files and me neither when a new 404 is detected...

  • If it really is just 100-150 old topics, then an nginx map makes even more sense.

    I can see it from your point of view, that it's easy for NodeBB to do, although I urge you to consider that nginx is very good at what it does, and so having nginx check for an old url to redirect is quite simple.

    For example, if the old forum had topics using this url: /t/<topic id>, then you could write a location block that only responded to that folder, and applied the map to redirect the user based on those topic IDs.

    In one example, we have this map config:

        map $request_uri $mapped_topic {
            ~^/showthread\.php\?(?<topicId>\d+).*$ $topicId;
            ~^/archive\/index\.php\/t-(?<topicId>\d+)\.html$ $topicId;
            default 0;

    and in the map file itself, we maintain the hash to go from one topic to another.

Suggested Topics