See SiteSettings.permalink_redirects
Edit: oops. Permalink normalizations
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
:
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.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 .
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.
Right. I missed that. You need to redirect /phpbb to /forum, and probably still fuss with normalizations
Right, but that indeed was not too hard: /^forum\/(view.*)/\1
works perfectly fine for our old phpBB permalinks. Not sure whether depending on settings there are other permalinks generated by the import plugin than viewforum.php
and viewtopic.php
, like possibly user profile links or such?
Would be actually nice to have a way to scroll/browse or sort permalinks, to better know which URLs schemes are contained. But OOT, and after looping through search patterns, I am certain that our case, only the two above exist.
It looks like the script does only category, topic, and post, permalinks.
If you wanted to create user permalinks and the user profiles on the old system include the user import_id, then you could create them with a bit of ruby at the console.
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:
/^forum\/(viewforum.php\?.*)/\1
for categories/^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.