How can I force WordPress to redirect to canonical permalinks?

Check whether the posts not being redirected actually have the correct permalink stored in the DB. There’s a bug in which canonicals can’t be properly guessed because the permalink structure was CHANGED after the post was created.

Try either creating a new post with your current permalink structure, or editing the post_name DB field for them. (There’s a plugin for updating the permalinks in DB)

The question remains.
ASSUMING it is still happening:

How do we FORCE wordpress to REDIRECT to the canonical url?
No just adding a link to it, but REDIRECTING to that page.

I changed the permalinks structure of the site, and added a add_rewrite_rule in functions.php, so now the old /02/20/2008/postname addresses are accepted and canonicalized as /blob/postname correctly… and the page is found successfully.

But no matter what I do, the canonical just stays as a link in the old URL’d page, still showing the wrong url in the adress bar.

NO REDIRECT is performed.

Ive worked with another website before, and I ended up (after days of trying tens of different pieces of code) using .htaccess redirects.

I know .htaccess redirects will work, but now that I read everywhere that “It should” be doing it… I’m wondering: Should it? and more exactly “how do I FORCE it?

Leave a Comment