Cross-domain problems with CSS loading fonts

Source: Internet
Author: User

Copyright NOTICE: This article is the original article of the blogger, without the permission of the blogger may not be reproduced.

Just ran into a CSS loading font cross-domain problem, record ah.

A site's dynamic request is a different domain name than a static file request. The domain name of the site is www.domain.com, while the static file's domain name is st.domain.com.

Problem:

Page loading CSS file: <link rel= "stylesheet" href= "Http://st.domain.com/css/uniform.css"/>

External fonts are called in this CSS:

@font-face {
  font-family: ' Fontawesome ';
  Src:url ('.. /font/fontawesome-webfont.eot ');
}

The browser has requested a cross-domain error.


Solution:

We use access-control-allow-origin:* to resolve cross-domain problems by enabling cors.

The specific steps are as follows:

1. Open the Apache mod_headers module

LoadModule Headers_module modules/mod_headers.so

2. Add in st.domain.com Host configuration

Header Set Access-control-allow-origin http://www.domain.com (this sentence can also be added to the URL rewrite file)

Restart Apache.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.