• Hello, I am looking for a solution to “redirect old canonical URLs to a new canonical URL automatically” I tried adding function this way but it doesn’t work

    //canonical - old domain to new domain
    
    add_filter('wpseo_canonical', 'swpseo_canonical_domain_replace');
    	
    function swpseo_canonical_domain_replace($url){ 
      $domain = 'new-domain.com';// new-domain.com		
      $parsed = parse_url(home_url());		
      $current_site_domain = $parsed['host'];			
    return str_replace($current_site_domain, $domain, $url);
    			
    }
  • The topic ‘redirect old URLs canonical to a new URL canonical’ is closed to new replies.