0

So I've experimented with different themes and have determined this is a WordPress thing and not a theme thing.

Say I create a page titled "The Front Page", then set it as the front page on reading settings under Front page displays.

After doing so the following URLs will all display the front page:

  • domain.com/page/50
  • domain.com/page/10000000

I'm assuming this COULD have negative SEO side effects. Aside from this though, shouldn't WordPress be throwing 404's on these URLs?

4
  • The fact that they display the homepage doesn't mean that it doesn't return a 404. Check the console, it might be a 404 there. How did you setup your 404 page? Commented Jun 17, 2015 at 22:28
  • There is no 404 header sent. I've tested this with multiple themes including Twenty Fifteen. Commented Jun 17, 2015 at 22:29
  • So pages like this domain.com/dasdasdas return a 404 but when it is domain.com/page/50 domain.com/page/ they return the homepage with no 404 in the console? Commented Jun 17, 2015 at 22:33
  • Do domain.com/page/50 and domain.com/page/10000000 actually exist as separate pages?
    – user33056
    Commented Jun 18, 2015 at 0:13

1 Answer 1

1

In WordPress you have 3 main kind of "views":

  • singular pages
  • archives
  • search

"Standard" home page is just a somewhat special archive page, a static front page a somewhat special singular page.

When you use the endpoint page in front page url, WordPress internally sets the query variable page to a specific number (would be paged for regular pages).

The problem is that paged is a query var that in WordPress makes sense only for archive and search views, in fact there's no pagination for a single result in database.

In short, WordPress recognizes that the url is formally correct, but ignore the query var it sets.

In fact, if you try to do same thing with any other page (that is not front page) the behavior is the same.

In short, those urls even if are not the "canonical" urls don't result in 404 because they correspond to a valid set of query vars, that returns a non-empty result.

With singular posts, this does not happen because WordPress, for posts, does a redirect the the "canonical" url.

WordPress does not do the same for front page and regular pages, because a lot of people use them as entry point for archives of posts, where pagination makes perfectly sense.

So in a costs / benefits balance WordPress prefer do not redirect pages to their canonical url by default.

Even because, regarding SEO, this is not something that really has bad effects, unless you have all around the web links that point to the home page url with /page/xxx appended.

And in that case, if such urls are not valid anymore, should be your care 301 redirect them.

By the way, you can force WordPress to apply canonical redirect also for pages and front page:

add_action('template_redirect', function() {
    if (
        (is_page() && get_query_var('paged'))
        || (
             is_front_page()
             && get_option('show_on_front') === 'page'
             && get_query_var('page')
        )
    ) {
        wp_safe_redirect(get_permalink(get_queried_object_id()), 301);
        exit();
    }
}, 99);

As alternative, you can also force 404 on those urls. IMO it has no real benefit for SEO over the 301 redirect, but has negative effects on users that don't se the page anymore.

By the way that's the code:

add_action('template_redirect', function() {
    if (
        (is_page() && get_query_var('paged'))
        || (
             is_front_page()
             && get_option('show_on_front') === 'page'
             && get_query_var('page')
         )
    ) {
        global $wp_query;
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();
        locate_template(array('404.php', 'index.php'), true);
        exit();
    }
}, 99);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.