0

I have come across an error when trying to access my site with http://www.example.com instead of http://eample.com. My font icons will not load. So when searching for the solution to this I came across the following solution which was adding the below code to a .htaccess file on the server.

<FilesMatch "\.(svg|ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "http://example.com, http://www.example.com"
</IfModule>

This managed to fix the problem but for Chrome only. How can i fix the issue for all browsers.

Thank you

psycho
  • 1,539
  • 4
  • 20
  • 36
  • 1
    How are you including your fonts? The fix could be as simple as using relative URL's not absolute, instead of messing around with your .htaccess file. – Karl Oct 02 '14 at 08:38
  • fonts are stored in a directory called fonts in the root. Then the css file i am using the href="http://example.com/css/font-awesome.min.css" – psycho Oct 02 '14 at 08:45
  • The issue would be resolved if you enforced the WWW cname. Might be a possible duplicate of [apache redirect from non www to www](http://stackoverflow.com/questions/1100343/apache-redirect-from-non-www-to-www) – Ohgodwhy Oct 02 '14 at 08:47

1 Answers1

1

Try using:

href="/css/font-awesome.min.css"

This will be relative to the domain they visitor is on, so if they connect to either http:// or http://www the fonts will load and there won't be a cross domain error

Karl
  • 5,435
  • 11
  • 44
  • 70
  • 1
    Thanks Karl I fixed the issue thanks to your answer. The orginal reason I was not using /css/... was becasue I was storing my header content in a seperate header.php file and then including it in all other files. This meant that if a page was stored in a subfolder the /css/... path would break. Therefore I had to define a constant that took in the url entered into the browser and added that to all css and js links. – psycho Oct 02 '14 at 09:35