# 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");

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.

Leave a Reply

Your email address will not be published.