4 ms·
great spot! I noticed that his server also doesn't accept URLs ending is a single `/`: https://chrismorgan.info/no-query-strings/ https://chrismorgan.info/no-q
by varenc 5mo ago
great spot!
I noticed that his server also doesn't accept URLs ending is a single `/`: https://chrismorgan.info/no-query-strings/ https://chrismorgan.info/no-query-strings/
But instead of the banned query strings message, it just returns a very sassy not-a-404 page. Once again, this is violating a common convention, but there's nothing in the HTTP spec that requires treating these URLs the same. Similarly the site also 404s when you add extra slashes like https://chrismorgan.info///no-query-strings https://chrismorgan.info///no-query-strings
digression: I love trying "domain.com//" on various sites. Occasionally it'll trigger weird errors like a 502 or 500.
- chrismorgan 5mo agoYou’re misreading a couple of things. There’s no violation of common convention where you’re pointing. Where dealing with static file servers: For URLs that are supposed to include a trailing slash and the server will find that directory and serve its index.html: it’s customary, though not ubiquitous, to redirect from no-slash to slash. (Some, including popular commercial services, serve the index.html file instead of redirecting to add the slash. This is extremely wrong because it changes the meaning of relative URLs.) But the other way round is not common. My URLs don’t include a file extension, and I think that’s influencing your perception into thinking no-query-strings is logically a directory name. But it’s not, it’s logically a file name, just with the .html removed as unnecessary. Take https://susam.net/no-query-strings.html https://susam.net/no-query-strings.html as an example; Susam is more clearly just serving from a file system than I am, and leaves the “.html” file extension in the URL. Do you expect https://susam.net/no-query-strings.html/ https://susam.net/no-query-strings.html/ to work? I hope not. It’s a 404, just as I’d expect, because there is no directory with that name. > not-a-404 page No, that’s a 404, just a plain old boring 404, same as any other. In fact, it’s the same 404 page I’ve been using since 2019, just with dark mode support added. > extra slashes Ah, now for that I had to go out of my way, because Caddy misbehaves out of the box: https://chrismorgan.info/Caddyfile#:~:text=%40has%5Fmultiple%5Fslashes,404 https://chrismorgan.info/Caddyfile#:~:text=%40has%5Fmultiple... > digression: I love trying "domain.com//" on various sites. Closely related is adding the trailing dot of a fully-qualified domain name: https://example.com./ https://example.com./. I didn’t remember to try this on my new site, but it turns out Caddy won’t talk at https://chrismorgan.info./ https://chrismorgan.info./, so that’s probably good.
- xp84 5mo agoI've seen a lot of headaches caused by that trailing dot in the past! IIRC Caddy specifically said they wouldn't support that, leading to a medium-sized flamewar in an issue or PR. Clearly the trailing dot is theoretically highly appropriate, but it seems like we're so far down the opposite path that we should all agree that every domain, sadly, should always be fully qualified.