My old forum URLs are in the form of /posts/t{topic_id}-{url_slug}.
I have used Discourse’s Permalink to maps the old forum URL to the new Discourse URLs.
The problem is that the Rails Router is routing requests for the old forum URLs to one of the routes associated with the “posts” resource. (I do not know which route.)
The Permalink Normalization runs after the routing is done so that is not a solution.
I think the solution is to add a custom route in the config\routes.rb to skip the request handling by the PostsController if the URL is in the form of /posts/t{topic_id}-{url_slug}, but I am not verse enough in Rails Routing to make this change. Or, maybe this is not the way?
What do they look like? What are the permalinks you added?
Is the forum live already or can you still run the import script? (Actually, you can make a Ruby script that you can run in Rails to add Permalinks like those that I describe.)
I think maybe you want to make your Permalinks something like /oldforum/{topic_id} and then to add some configuration to nginx to catch those /posts/t URLs and remap those to /oldforum/{topic_id}.
So (according to AI) you’d do a replace with pups (sometime soon you can add it to an outlet, but I don’t know when that’s going to happen) to add this to your discourse.conf nginx config:
# Place this inside your server {} block
location ~ ^/posts/t(?<topic_id>\d+)-.*$ {
# Permanent redirect (301)
return 301 /oldforum/$topic_id;
# Alternatively, for temporary redirect (302), use:
# return 302 /oldforum/$topic_id;
}
I’d test it by making those changes by hand inside the container and then work backward to add the changes to your app.yml.
I found out this solution may be a no-go because the redirect chain will affect the site’s SEO score. It takes two 301 redirects and three requests to get to the actual post.
And then, letting the Permalink handle the request. It sounds like it should work but I am not sure.