How to solve the problem that Font Awesome is not displayed in Firefox under Apache/Nginx

王林
Release: 2023-05-21 17:43:06
forward
1260 people have browsed it

1. nginx server solution

The server uses nginx. To add the access-control-allow-origin field to the response header, the adding method is to use the add_header directive:

Configuration example:

Copy code The code is as follows:

location /assets/ {
gzip_static on;
expires max;
add_header cache-control public;
add_header access-control-allow-origin *;
}

2. Apache server solution

font awesome (firefox cannot display Firefox Unable to display) cross domain (cross domain problem)

the problem

it seems that, for security reasons, firefox simply don't allow you to use by default a font that is not hosted on your domain, not even on your subdomain. the cdn based websites can be also affected in this case.

the solution

after some investigations , i found out the workaround: set a access-control-allow-origin header to the font.

Copy code The code is as follows:



header set access-control-allow-origin "*"

Also, if you are using nginx as your webserver you will need to include the code below in your virtual host file:

Copy code The code is as follows:

location ~* \.(eot|otf|ttf|woff)$ {
add_header access-control-allow-origin *;
}

The above is the detailed content of How to solve the problem that Font Awesome is not displayed in Firefox under Apache/Nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!