Migrate a phpBB3 forum to Discourse

See SiteSettings.permalink_redirects

Edit: oops. Permalink normalizations

You mean at /admin/site_settings/category/all_results search for permalink_redirects? That setting does not exist for me.

But permalink_normalizations sort of works, using /^forum\/(view.*)/\1:

  • All phpBB links begin with view, like viewtopic.php and viewforum.php. Actually those seem to be the only two URLs migrated in our case, so the regex could be hardened, or split into two for full path matching.
  • So that regex (sed syntax) takes all URLs which start with /forum/view, and removes the forum/ part.

Now we only need to redirect all /phpbb/ (our old forum path) to /forum/ at the webserver (or Cloudflare in our case) and Discourse does the remains. Should have found this ~3 years ago, instead of breaking all backlinks :smiling_face_with_tear:.

But let me know where this permalink_redirects is supposed to be, maybe it requires a plugin, or was part of the phpBB import plugin or so?

EDIT: Works well:

root@micha:~# curl -IL https://dietpi.com/phpbb/viewtopic.php?p=46083
HTTP/2 301
location: /forum/viewtopic.php?p=46083

HTTP/2 301
location: https://dietpi.com/forum/t/is-there-a-simple-launch-page-for-dietpi/11237/1
x-discourse-route: permalinks/show

HTTP/2 200
x-discourse-route: topics/show

First redirect /phpbb => /forum happens at Cloudflare via redirect rule, to keep trivial load away from our origin. Second redirect to actual topic is done at Discourse via permalink, removing the leading forum/ via permalink normalization, to match the permalinks added by the phpBB import plugin, which contain neither old nor new forum sub directory path.

Sorry. That’s what I meant.

No. Just make a normalization for that path.

That does not work, since Discourse lives at /forum and does not see any requests to /phpbb. With Discourse on a sub path, which does not match the path of the prior forum software to import, there is no way around doing a redirect (or rewrite before proxy) to the Discourse path, for its normalization to become effective.

1 like

Right. I missed that. You need to redirect /phpbb to /forum, and probably still fuss with normalizations

Oké, maar dat was inderdaad niet al te moeilijk: /^forum\\/(view.*)/\\1 werkt perfect voor onze oude phpBB permalinks. Niet zeker of er, afhankelijk van de instellingen, andere permalinks worden gegenereerd door de importplugin dan viewforum.php en viewtopic.php, zoals mogelijk gebruikersprofiel links of iets dergelijks?

Het zou eigenlijk fijn zijn om een manier te hebben om permalinks te scrollen/door te bladeren of te sorteren, om beter te weten welke URL-schema’s erin zitten. Maar OOT, en na het doorlopen van zoekpatronen, ben ik er zeker van dat in ons geval alleen de twee bovengenoemde bestaan.

Het lijkt erop dat het script alleen permalinks voor categorieën, onderwerpen en berichten maakt.

Als je gebruikerspermalinks wilde maken en de gebruikersprofielen in het oude systeem de user import_id bevatten, dan zou je ze met een beetje ruby in de console kunnen maken.

1 like

Good to know. And topic and post URLs use the same PHP script. So to rule out any unintended nomalization, my regex could be split into two:

  1. /^forum\/(viewforum.php\?.*)/\1 for categories
  2. /^forum\/(viewtopic.php\?.*)/\1 for topics and posts

… or /^forum\/(view(forum|topic).php\?.*)/\1, not sure whether any marginal difference performance-wise.

Profile URLs are anyway unlikely to have any backlinks. We use it to give users, who reported bugs or whose suggestions made it in our project, credits in our release notes. But that is a rare case, I guess, and links in our release notes have been updated immediately when we switched to Discourse.

1 like