Multi domains on 1 wordpress source

#896
  • Resolved Mike
    free

    Hello,

    I’ve just moved to Rank math from Yoast. I run multi site on only 1 wordpress source and I used this code to redirect all trafic to main domain:

    add_filter(‘wpseo_canonical’, ‘swpseo_canonical_domain_replace’);
    function swpseo_canonical_domain_replace($url){
    $domain = ‘mydomain.com’;// replace with your domain
    $parsed = parse_url(home_url());
    $current_site_domain = $parsed[‘host’];
    return str_replace($current_site_domain, $domain, $url);
    }

    Is there any solution on RM to run multi site on only 1 WP source without effecting SEO.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math today.

    Please use below filter code to change the canonical URL:

    
    add_filter( 'rank_math/frontend/canonical', function( $url ) {
        $domain = 'mydomain.com';// replace with your domain
        $parsed = parse_url( home_url() );
        $current_site_domain = $parsed['host'];
        return str_replace($current_site_domain, $domain, $url);
    });
    

    Hope that helps. Thank you.

    Thank you so much.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?filter=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Multi domains on 1 wordpress source’ is closed to new replies.