Missing WordPress Icons on two domain website caused by Cross-Origin Resource Sharing policy

Ahh missing fonts and icons and such caused by two domain names on one site.. This particular instance involved using Polylang plugin and one domain for each language accomplished by a second domain alias, which confused the server into denying access from the secondary language site to the font files.

“has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”

Make sure modheaders is installed with this:

 

a2enmod headers

add the following to your .htaccess file:

<IfModule mod_headers.c>
    <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
        Header set Access-Control-Allow-Origin "http://domain.com"
    </FilesMatch>
</IfModule>

Also make sure to replace “domain.com” with the alias domain name that you are trying to give access to the font files.

Also remember to clear your browser cache after changing the settings, if using chrome this is a great app: https://chrome.google.com/webstore/detail/clear-cache/cppjkneekbjaeellbfkmgnhonkkjfpdn?hl=en

Leave a Reply

Your email address will not be published.