WordPress URL stupidity

I have an apparently controversial opinion: that URLs that do not exist should return 404. WordPress disagrees, vehemently, and always tries to either redirect to "what you might have meant", or, even worse, just returns another document, allowing two different URLs to have the same content instead of redirecting to the canonical URL.

By default, if you type some random word into a URL like /blog/something it will spin the wheel and redirect to an arbitrary post that happens to have that word in it, like /blog/2004/09/actually-something-else/. You can disable that nonsense like so:

add_filter ('do_redirect_guess_404_permalink', '__return_false');

But this is insufficient because, for example, the post with the URL /blog/2022/12/sewers/ also answers to /blog/2022/00/sewers/, /blog/2022/0/sewers/, /blog/0000/00/sewers/, /blog/0000/0/sewers/, /blog/0000/0/SeWeRs/, and who knows what else. And those aren't even redirects, but multiple URLs returning the same document.

How do I make it knock that shit off?

I imagine the answer is somewhere in the parse_query filter, but that's the part of the map that is very clearly labelled "Here Be Monsters".

Previously, previously, previously.

Tags: , , , ,

My 50 most popular blog posts in 2022

This year I didn't omit posts not made in 2022, because there were a few pretty old ones making a comeback tour for some reason...

Previously, previously, previously, previously, previously.
Tags: , , , , , ,

  • Previously