Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong CSS/JS link in subdomain #6738

Open
bugrevealingbme opened this issue Jun 24, 2024 · 1 comment
Open

Wrong CSS/JS link in subdomain #6738

bugrevealingbme opened this issue Jun 24, 2024 · 1 comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting priority: low Issues that can wait severity: moderate Feature isn't working as expected but has work around to get same value type: bug Indicates an unexpected problem or unintended behavior

Comments

@bugrevealingbme
Copy link

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');
@bugrevealingbme
Copy link
Author

i fixed with: RewriteCond %{REQUEST_URI} /$

@piotrbak piotrbak added type: bug Indicates an unexpected problem or unintended behavior 3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting priority: medium Issues which are important, but no one will go out of business. severity: moderate Feature isn't working as expected but has work around to get same value labels Jul 3, 2024
@piotrbak piotrbak added priority: low Issues that can wait and removed priority: medium Issues which are important, but no one will go out of business. labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting priority: low Issues that can wait severity: moderate Feature isn't working as expected but has work around to get same value type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants