When a url is posted on a forum/chat, it’s often automatically made linkable. But sometimes the regexp that grabs the url also grabs a trailing punctuation mark. For example, if the text is “visit red blob (https://www.redblobgames.com) and scroll to the bottom” and regexp picks up the trailing parenthesis, it will make “https://www.redblobgames.com)” clickable. When you click on this, it will request GET /) which will be a 404 error.
I don’t get a lot of these in my server error logs but it’s easy to do something about it.
I use both nginx and Caddy for my web sites.
In nginx I can put a permanent rewrite inside the server block:
server { … rewrite ^(.*)[\;:,.)]$ $1 permanent; }
In Caddy the syntax is different:
https://www.redblobgames.com { … @trailing_punctuation path_regexp url ^(.*?)[;:.,\)]$ redir @trailing_punctuation {re.url.1} 301 }
Now it will 301-redirect “https://www.redblobgames/)” to “https://www.redblobgames/”.
For both of these web servers, I never remember what characters need to be escaped, and I kind of wish I could use existing programming language syntax with delimiters like /^(.*)[;:,.)]$/ or r'^(.*)[;:,.)]$'.