Home  >  Article  >  Operation and Maintenance  >  How to solve the problem that Font Awesome is not displayed in Firefox under Apache/Nginx

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

王林
王林forward
2023-05-21 17:43:061312browse

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete