当我在URL中没有“www”时,我遇到了SnapSVG试图加载SVG文件的交叉策略问题。
我更新了我的htaccess文件,以便SVG和webfonts有更宽松的策略,但如果我不包含“www”,它似乎不起作用
完整的HTACCCESS文件:
AddType image/svg+xml svg
AddType image/svg+xml svgz
AcceptPathInfo On
<FilesMatch "\.(ttf|otf|eot|woff|svg)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
# Looks for files and directories that do not exist
# and provide the segments to the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
CHROME中的错误:
OPTIONS http://www.adaptiveemails.com/assets/svg/computers.svg Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers. snap.svg-min.js:19
d.ajax snap.svg-min.js:19
d.load snap.svg-min.js:19
window.onload (index):481
XMLHttpRequest cannot load http://www.adaptiveemails.com/assets/svg/computers.svg. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.
答案 0 :(得分:0)
这是您收到的错误消息:
Access-Control-Allow-Headers 不允许使用请求标题字段 X-Requested-With 。
所以它似乎与执行“www”没有任何关系,你似乎没有在你的htaccess文件中有任何关于它的任何规则。尝试从访问控制标头集容器中删除“svg”:
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>