Pagination after switching themes

Hey folks,

I’m working with a client trying to get some 404s resolved. One weirdness he’s seeing in his search console is GoogleBot reporting 404s for pages like siteurl/tag/tagslug/page/24 . That would url resolve it it were page 3, but he doesn’t have 24 pages, so it 404s. My best guess is that he switched themes a couple times, and one of his past themes must have had fewer posts per page, resulting in that being a good URL.

I know how to do redirects, including with regex (since my client has also repeatedly changed his tag slugs I’m getting too good at it), but I’m a little stumped how to do this one. I think the idea behavior would be to redirect to the last page when the page number is too high, but I don’t see an obvious way to do that. I don’t really want to redirect the spuriously high page numbers to lower page numbers one at a time, since that will be a good URL again once my client makes more posts.

Has anyone seen something like this? Any tips?

I’m uncertain if this would work, or whether it’s precisely what you need, but this is how I was thinking this through. The idea is to always redirect pages 3 and over to a new page 3 for old tag only.

location ~ ".(oldslug1|oldslug2|oldslug3)/page/([1-9]{1,2})$" {

    if ($2 != "(1|2)" {
        redirect permanent;
    rediect$2 permant;

However, I think you’d also need to map old tag slugs with new slugs, which complicates matters further. So, maybe a location for each old tag?

I actually wouldn’t do anything here. That page no longer exists, so it should be 404ing. Google is picking up the 404 and will no longer index it. However, the existing pages will be picked up and indexed.

1 Like