# The more I look at it I'm convinced that the redirect issues are limited to specific posts, and one in particular.
I worked around it by doing things manually in my 404 template using preg_match
to identify if the url generating a 404 error matched the old permalink structure:
$erroruri = $_SERVER['REQUEST_URI'];
if ( preg_match('/\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/(.*)/i', $erroruri, $match) ) {
$newurl = "https://colinwalker.blog/" . $match[1];
header("HTTP/1.1 301 Moved Permanently");
header("Location: $newurl");
exit;
}
It works fine but in testing one post (at least that I know of) causes an issue when loaded whether any form of redirect is in place or not, regardless of whether I try to access it via old or new permalink format.
I think I may have to delete and recreate it.
Comments
# I recreated the problem post and everything appeared okay so set about diving into the database to re-associate comments with the new version.
The problem came back.
It appears that one of the comments on the post had become corrupted somehow and was causing the loop. With this removed I think we're back to normal.
# I found a second corrupted comment on a different post. I don't like the direction this is heading.
Comments
# Liked: Flashing Palely in the Margins...
"It doesn’t have to be this way, but anyone who is shocked that it is this way, right now, has been willfully ignorant. That ignorance makes everything worse."
This is such a powerful piece on inequality and how being shocked by the unfair treatment of minorities is definitely the wrong reaction.
To be shocked is to ignore that it happens all the time like shootings in the US or knife attacks in London.
Be angry, be disgusted, but don't be shocked or surprised - we're so far past that.
My commute home was spent fixing the display of "related posts" in the comments. It's supposed to show the post title but I still had a number of posts from last year that had none - from before I started automatically replacing them with the date/time. Even after adding the date/time to those there were still instances of related posts being listed with no page title. I couldn't figure out why until I realised they were from before I changed the permalink structure - the redirects were preventing the page source being loaded via curl. I, therefore, had to reuse the code snippet from my 404 page to grab the new, redirected URL. Problem solved!