如果没有www,webfont就不会出现

时间:2014-09-07 12:10:27

标签: css .htaccess webfonts

我试图到处找到答案。我有一个唱歌网站www.hugeone.co.uk。当地址就像在这个链接(用www。)一切都好。但是,如果我只输入hugeone.co.uk网页字体,则不会出现,我收到消息:

  

阻止跨源请求:同源策略禁止读取   远程资源在   http://www.hugeone.co.uk/includes/templates/huheone/css/fonts/dirtyheadline-webfont.woff。   这可以通过将资源移动到同一个域来修复   启用CORS。

我的.htaccess文件:

RewriteEngine On

# Don't rewrite any URIs ending with a file extension (ending with .[xxxxx])
RewriteCond %{REQUEST_URI} !\.[a-z]{2,5}$ [NC]
# Don't rewrite any URIs for some, popular specific file format extensions,
#   which are not covered by main file extension condition above
RewriteCond %{REQUEST_URI} !\.(mp3|mp4|h264)$ [NC]

RewriteCond %{REQUEST_URI} !^/editors/ [NC]
# Don't rewrite .settings directory
RewriteCond %{REQUEST_URI} !^/\.settings/ [NC]
# Don't rewrite ajax_bin directory
RewriteCond %{REQUEST_URI} !^/ajax_bin/ [NC]
# Don't rewrite artwork directory
RewriteCond %{REQUEST_URI} !^/artwork/ [NC]
# Don't rewrite bigdump directory
RewriteCond %{REQUEST_URI} !^/bigdump/ [NC]
# Don't rewrite bmz_cache directory
RewriteCond %{REQUEST_URI} !^/bmz_cache/ [NC]
# Don't rewrite catal directory
RewriteCond %{REQUEST_URI} !^/catal/ [NC]
# Don't rewrite catdescr directory
RewriteCond %{REQUEST_URI} !^/catdescr/ [NC]
# Don't rewrite ebay directory
RewriteCond %{REQUEST_URI} !^/ebay/ [NC]
# Don't rewrite feed directory
RewriteCond %{REQUEST_URI} !^/feed/ [NC]
# Don't rewrite fonts directory
RewriteCond %{REQUEST_URI} !^/fonts/ [NC]
# Don't rewrite ftp-uploads directory
RewriteCond %{REQUEST_URI} !^/ftp\-uploads/ [NC]
# Don't rewrite harvest directory
RewriteCond %{REQUEST_URI} !^/harvest/ [NC]
# Don't rewrite invoices directory
RewriteCond %{REQUEST_URI} !^/invoices/ [NC]
# Don't rewrite jobs directory
RewriteCond %{REQUEST_URI} !^/jobs/ [NC]
# Don't rewrite logo directory
RewriteCond %{REQUEST_URI} !^/logo/ [NC]
# Don't rewrite londynek directory
RewriteCond %{REQUEST_URI} !^/londynek/ [NC]
# Don't rewrite phpmyadmin directory
RewriteCond %{REQUEST_URI} !^/phpmyadmin/ [NC]
# Don't rewrite populate directory
RewriteCond %{REQUEST_URI} !^/populate/ [NC]
# Don't rewrite temp directory
RewriteCond %{REQUEST_URI} !^/temp/ [NC]
# Don't rewrite test directory
RewriteCond %{REQUEST_URI} !^/test/ [NC]
# Don't rewrite uploads directory
RewriteCond %{REQUEST_URI} !^/uploads/ [NC]
# Don't rewrite very_secret directory
RewriteCond %{REQUEST_URI} !^/very_secret/ [NC]
# Don't rewrite video directory
RewriteCond %{REQUEST_URI} !^/video/ [NC]
# Handle all other URIs using Zen Cart (its index.php)
RewriteRule .* index.php [QSA,L]

## END CEON URI MAPPING REWRITE RULE

#WEBFONTS

AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff

<FilesMatch "\.(ttf|otf|eot|woff)$">
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
</FilesMatch>

我不知道我能做些什么。

2 个答案:

答案 0 :(得分:1)

如果将所有非WWW请求重定向到WWW是一个选项,您可以执行此操作:

RewriteCond %{HTTP_HOST} ^hugeone\.co\.uk$ [NC]
RewriteRule ^ http://www.hugeone.co.uk%{REQUEST_URI} [R=301,L]

在下面添加:

RewriteEngine On
# optional you might not have the below in your file.
RewriteBase /

.htaccess文件中。

上面的替代方法是使用您的.htaccess为网络字体启用CORS,如下所示:

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

作为旁注,如果您不同时使用WWW和非WWW,Google会更好,因为谷歌并不喜欢同时使用它们。

答案 1 :(得分:0)

网址和值都应该相同。

在这种情况下可以采用两种解决方案。

  1. 将所有非www请求重定向到www

  2. 根据网址更改基本href值。