Facebook fbclid pollution -- can it be prevented?

So I really love the permalinks feature of Discourse.

For example, I’ve been collecting photos and videos at https://fortmactech.com/riverbreak – which forwards to the longer URL of the actual topic.

The problem I’m running into is that when that’s posted on Facebook and someone clicks it, Facebook appends its fbclid crap at the end. So the URL is something like:


And it generates a 404 on Discourse.

Is there a trick to getting Discourse to ignore the fbclid parameter?


So I think this is something that can probably be done with the Permalinks Normalization setting, but I can’t figure out the regex. Basically remove anything after and including ?fbclid= I think.

Interested in this too. This is polluting our Google Analytics data.


So I’ve been able to solve it with a Cloudflare page rule:

Screen Shot 2021-04-14 at 9.27.33 AM

But would rather do it at the discourse level instead.

How are you forwarding https://fortmactech.com/riverbreak to https://fortmactech.com/t/river-drone-videos-photos-2021/818?

It seems that adding query parameters to the topic URL doesn’t cause any issues. For example, this should work: https://fortmactech.com/t/river-drone-videos-photos-2021/818?fbclid=IwAR1E9PoBxuWURZRJlA4D0VrnESbfjGfC2xKuvVJzCRUmIJy7ZRKMkkH8I-U. So the issue is somehow related to the redirect that’s in place for https://fortmactech.com/riverbreak.

1 Like

I’ve sort of solved it now by using Cloudflare. I have turned off the Cloudflare page rule for a while if you want to see the 404 happening.

Try this link as an example:



I added it like this in admin / settings / permalinks:


This is what it looks like once it’s added:


Screen Shot 2021-04-14 at 10.28.01 AM


And the result is this:


I’ve tried with a trailing slash as well.

If I do the Cloudflare Page Rule to remove the fbclid stuff before it hits Discourse, then it works just fine.

Is this what the Discourse “Permalinks Normalization” is for? Would I be able to strip out anything after ? using that setting?

1 Like

Thanks for the details. It seems that query parameters break Discourse permalink redirection. I’m not sure if that is expected to happen.


It’s definitely expected, it’s heavily used for permalinks that have e.g. forum.php?topic_id=1234.


That makes sense. Is there a way to “transform” an incoming URL before it’s analyzed by the permalinks code? Is that the “Permalinks Normalization” feature?

Yes that’s exactly what permalink normalizations is for :smiley:


Can someone give me an example of how I would get rid of ?fbclid= and anything after it, using the Permalinks Normalization setting? Thanks :slight_smile: