I set up a subdomain with Polylang. The CSS and JS on the pages should come from the main domain, but it adds the subdomain link to them and the page breaks. I tried excluding subdomains from the cache, but this does not work.
Also i tried this function:
function replace_subdomains_with_main_domain($url) {
global $subdomains, $main_domain;
foreach ($subdomains as $subdomain) {
if (strpos($url, $subdomain) !== false) {
return str_replace($subdomain, $main_domain, $url);
}
}
return $url;
}
// CSS, JS ve ekli medya URL'leri için filtreler
add_filter('stylesheet_uri', 'replace_subdomains_with_main_domain');
add_filter('script_loader_src', 'replace_subdomains_with_main_domain');
add_filter('style_loader_src', 'replace_subdomains_with_main_domain');
add_filter('wp_get_attachment_url', 'replace_subdomains_with_main_domain');
add_filter('wp_get_attachment_image_srcset', 'replace_subdomains_with_main_domain');
add_filter('the_content', 'replace_subdomains_with_main_domain');
add_filter('rocket_buffer', 'replace_subdomains_with_main_domain', 999999);
add_filter('rocket_cache_reject_cookies', 'replace_subdomains_with_main_domain');
I set up a subdomain with Polylang. The CSS and JS on the pages should come from the main domain, but it adds the subdomain link to them and the page breaks. I tried excluding subdomains from the cache, but this does not work.
Also i tried this function: