WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
404 errors in canonical url for some search pages (6 posts)

  1. MaTheRyS
    Member
    Posted 2 years ago #

    WordPress version: 3.4.1
    WordPress SEO version: 1.2.5

    I did this: i installed WP SEO 1.2.5, imported data from All in One SEO, desactivated AiO SEO and activated WP SEO 1.2.5

    I expected the plugin to do this: put the right canonical url in all pages

    Instead it did this: for some search result pages, the canonical url go to a 404 page.
    For exemple, this page http://www.dropshipping-france.fr/search/boutique+dropshipping/page/2/ has the canonical url :
    http://www.dropshipping-france.fr/search/boutique%2Bdropshipping/page/2/ that give a 404 page.
    It seems to be a problem with :
    %2B and + in canonical urls

    But it is strange because it seems to append only for some search pages and not for all...
    This page http://www.dropshipping-france.fr/search/boutique+ligne/
    Has a good canonical :
    http://www.dropshipping-france.fr/search/dropshipping+dropshipper/

    GWT alert me that it found a lot of 404 erros (more than 30) and all are coming from a bad canonical since i've installed the plugin.

    What can i do please ?
    Thanks.

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. MaTheRyS
    Member
    Posted 2 years ago #

    Some additional informations :
    The link rel="next" and link rel="prev" have the same problem.
    %2B is not transformed in +

    For now, i've just put a temporary solution by adding :
    $canonical = preg_replace( '/\%2B/', '+', $canonical );
    in the function "function canonical"

    and

    $url = preg_replace( '/\%2B/', '+', $url );
    in the function "adjacent_rel_links()"

    But... Is this a good solution ? And why does this problem happend ?

  3. vijayrajesh
    Member
    Posted 1 year ago #

    Hi,

    I am also getting this error. any solutions Yoast?

  4. vijayrajesh
    Member
    Posted 1 year ago #

    Were you able to get any better solution?

  5. vijayrajesh
    Member
    Posted 1 year ago #

    Hi,

    This is what i have done now to fix the errors.

    The following line

    echo '<link rel="canonical" href="' . esc_url( $canonical, null, 'other' ) . '" />' . "\n";

    is converted to

    echo '<link rel="canonical" href="' . esc_url( urldecode($canonical), null, 'other' ) . '" />' . "\n";

    And I have added

    $url = urldecode($url);

    to the next line of

    $url = $this->canonical( false, true );

    I am not sure it is a right solution as it touches the core of plugin. Anyway, it works for site.

  6. vijayrajesh
    Member
    Posted 1 year ago #

    I am just updating this thread.

    The file i modified is at /wp-content/plugins/wordpress-seo/frontend/

    The filename is class-frontend.php

    Thank you,

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags