The discourse/forest integration (the crossposting that happens when you put \meta{comments}{true}
in the heading of a forester post) has been subtly bugged for a while, because discourse decides to convert the forest url to lowercase. I had fixed this before by manually generating a cloudflare redirect for every forest page with a uppercase letter in it from the lowercased version, but then I moved off cloudflare and that didn’t work anymore. I now fixed it with openresty
and the following piece of code in nginx.conf
rewrite_by_lua_block {
local uri = ngx.var.uri
local matches, err = ngx.re.match(uri, "^/(\\w+)-([0-9a-z]{4})\\.xml$")
if matches and not err then
local new_uri = "/" .. matches[1] .. "-" .. string.upper(matches[2]) .. ".xml"
return ngx.redirect(new_uri, ngx.HTTP_MOVED_PERMANENTLY)
end
}
As a consequence, forest links of the form xxx-yyyy
will now redirect to xxx-YYYY
. This is not a perfect workaround for discourse’s lowercasing; in particular it will not fix the case where you have uppercase letters in the xxx
part. I suggest simply not doing that.
If you didn’t understand any of this, just know that localcharts is now slightly less broken.