MiG
2021 年4 月 12 日 04:44
1
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:
https://fortmactech.com/riverbreak?fbclid=IwAR1E9PoBxuWURZRJlA4D0VrnESbfjGfC2xKuvVJzCRUmIJy7ZRKMkkH8I-U
And it generates a 404 on Discourse.
Is there a trick to getting Discourse to ignore the fbclid parameter?
4 个赞
MiG
2021 年4 月 14 日 14:51
2
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.
rmens
2021 年4 月 14 日 15:20
3
Interested in this too. This is polluting our Google Analytics data.
2 个赞
MiG
2021 年4 月 14 日 15:28
4
So I’ve been able to solve it with a Cloudflare page rule:
But would rather do it at the discourse level instead.
simon
2021 年4 月 14 日 16:21
5
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 个赞
MiG
2021 年4 月 14 日 16:32
6
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:
https://fortmactech.com/riverbreak?fbclid=IwAR1E9PoBxuWURZRJlA4D0VrnESbfjGfC2xKuvVJzCRUmIJy7ZRKMkkH8I-U
I added it like this in admin / settings / permalinks:
This is what it looks like once it’s added:
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 个赞
simon
2021 年4 月 14 日 16:36
7
Thanks for the details. It seems that query parameters break Discourse permalink redirection. I’m not sure if that is expected to happen.
4 个赞
riking
(Kane York)
2021 年4 月 14 日 17:25
8
It’s definitely expected, it’s heavily used for permalinks that have e.g. forum.php?topic_id=1234
.
3 个赞
MiG
2021 年4 月 14 日 17:30
9
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?
justin
(Justin DiRose)
2021 年4 月 14 日 18:38
10
Yes that’s exactly what permalink normalizations is for
2 个赞
MiG
2021 年4 月 14 日 18:51
11
Can someone give me an example of how I would get rid of ?fbclid= and anything after it, using the Permalinks Normalization setting? Thanks