[Yoast SEO] Change domain name behind proxy

[ad_1]

Hello,

I am trying to change the domain name in the metatags autogenerated by Yoast SEO. The issue is I have two separate domains i.e one is the main domain eg: www.abc.com and another domain eg: www.prod.abc.com, used as a reverse proxy. The actual content is in the backend domain. The home and siteurl are configured dynamically, the links are autogenerated in the backend with domain name www.prod.abc.com. I want to change it to the main domain name i.e. www.abc.com.

Here is an example of how I can change the canonical links,
“`
add_filter( ‘wpseo_canonical’, function( $canonical ) {
if( ‘https://www.abc.com’ == get_option( ‘home’ ) ) {
return $canonical;
}

$canonical = preg_replace(‘#//[^/]*/#U’, ‘//www.abc.com/’, trailingslashit( $canonical ) );
return $canonical;
});
“`

I want to change all links to www.abc.com

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer