Chrome:
"Font from origin 'https://example.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.example.com' is therefore not allowed access."
My .htaccess file looks like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301,NC]
Redirect 301 / https://example.com
Then I added this to the bottom of the file:
Header add Access-Control-Allow-Origin "*"
...and cleared cache same issue.
...then per this article: Font blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin'
I added these lines and replaced my domain with example.com:
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://example.com"
</IfModule>
</FilesMatch>
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://www.example.com"
</IfModule>
</FilesMatch>
My entire .htaccess looks like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301,NC]
Redirect 301 / https://example.com
Header add Access-Control-Allow-Origin "*"
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://example.com"
</IfModule>
</FilesMatch>
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://www.example.com"
</IfModule>
</FilesMatch>
Any help here?
Redirect
directive looks out of place... that will either result in a redirect loop, but's missing a trailing slash on the target URL (which will result in a malformed request?!), or the user/request is redirected to a "different server" so the remaining directives are not being executed?!https://www.example.com/...
throughout your application? Why do you have 2<FilesMatch>
wrappers? The secondHeader set
will simply overwrite the first. (However, I'm still stuck on that earlierRedirect
directive - I can't see how this is working at all?)