Fixing missing Disqus comments though the URL map tool

I noticed the other day that Disqus comments that were appearing on my site stopped showing up. Articles that had had 2 or 3 comments had started saying “no comments”.

Minor URL changes

After looking into it for a while, and googling a little bit, I realised that the reason was because I had made a slight change to the way my URLs are structured. For example: ->

I had very carefully made sure all the old URLs redirected properly to the new ones.

The problem

Disqus didn’t care that I’d taken all this care to create redirects. All it knew was that people had commented on an article at ../optimal-font-size.html and now they were asking to see comments at ../optimal-font-size/ (with a / in place of .html), which isn’t the same thing at all, apparently.

Incidentally I think that this was a bit shit of Disqus - they should use 301 Permanent redirects to link URLs automatically to avoid this issue.

Solution outline

Disqus, to their credit, created a tool called “URL map”.

You can find the tool inside your Disqus admin area under Discussions -> Tools and use it to replace old incorrect URLs with the new ones.

Solution details

When you go to your Disqus admin area (filtered by site, if you like), you can click “Discussions” and then “Tools” and then “Start URL mapper”.

Download existing URLs in CSV format

Now you can download the CSV of your existing URLs by clicking “you can download a CSV here”. This is definitely a good idea.

Open it up in your favourite text editor. It will look just like a list of URLs:

You want to edit it to add in replacement URLs, so it looks something like this:,,,

Make it easier using regex in sublime

I edited it using sublime text - a fantastic editor, which support regular expressions. I used the following find and replace statement to transform the file into what I wanted it to be:

^(http://[^/]+)([^ .\n]+[^/.\n])/?(.html)?[^\n]*$

Which made it so much easier. If your requirements are similar to mine you can probably manage to copy this and tweak it slightly yourself. If they’re different, you’ll have to learn regex to use this solution if you don’t already know it.

Upload the file

Now I uploaded the file back to Disqus through the URL map tool, waited a few minutes, and voila! My old comments showed up under my new URLs!

As the tool will tell you, the only way to check this is to check if the missing comments start showing up again.

By @nottrobin