How to import bbPress images and links redirect 301 to Discourse?


I handled to transfer all the contents of bbPress to to Discourse “development environment”, by use bbpress.rb script.

but I have two questions that I would help with:

1: All the images appear on the Discourse with this path “/wp-content/uploads/img_644e48aedc2bf.jpg” it the same bbPress media url path , how can I import the images as well so that they move to the expected path on Discourse?

2: my bbPress default permalink were like this "", bbPress uses permalink also


in sql… my question is how can I edit bbpress.rb code so that can import old links and redirct to new Discourse links 301 without any problem later?

so, when the user tries to visit the old site

, the link is redirect 301 to the new one


can you give me a hand with these questions?

Hi there,

For 1, you will need to change the bbpress script to copy the avatars from the folder, and upload them to your Discourse instance. You can check the vbulletin import script for an idea on how that could be achieved, on line 212.

As for 2, that is actually going to be a bit more complicated since Discourse can’t access external websites’ data (like So the best way to achieve that would be to keep the same domain, and make some slight changes to the create_permalinks (line 379) function to support the postname parameter.

1 Like

If you mean in posts, then if you have download remote images to local set, Discourse will download them. There are sidekiq jobs that should run to do that.

You can look at other scripts for “Permalink”.

In short, the p=123 values should be stored in TopicCustomFields or PostCustomFields with name import_id and you can then run a script to create the permalinks.

1 Like

A few minutes ago, I activated “download remote images to local” and downloaded all the images to the local server “bbPress” . How can I activate the sidekiq jobs to let Discourse download them during import?

apologise for the inconvenience, how do I redirect all links from


I don’t think %postname%/ is the same

You just need to wait for them to finish. If you’d rather modify the script to have it handle the uploads when it runs, you can look at other scripts that do that.

You can look at other scripts that create Permalinks. vbulletin.rb has an example of permalinks.

The existing bbpress.rb handles attachments that are in the database, so you must have users who linked directly to them, or something like that? So you’d need to find them with a regex and then handle them the way that the other upload functions do. If Discourse is handling them, then you might rather just let it, as I suspect that’s going to work.

1 Like

Thank you @pfaffman @nizar9

I was able to save and transfer all the images from the old bbPress articles to Discourse by enabling the download remote images feature in the control panel

But :cry: I’m still stuck to redirect 301 old bbPress links like this


to the new link


And I can’t solve the problem through htaccess regular expression because I don’t know what’s new id for the same topic.

You cannot. There is at least one import script that will dump out data so that you can. As I said earlier, it’s possible to create Permalink redirects to solve the problem in Discourse.