联系官方销售客服

1835022288

028-61286886

开发框架 版主:迅睿框架研发组
字体跨域问题与域名识别跳转两个疑问运行环境本地线上为阿里云万
类型:迅睿CMS 更新时间:2020-10-26 21:28:24 跨域 后台

字体跨域问题与域名识别跳转两个疑问

  1. 运行环境:本地phpstudy8.1 amp,线上为阿里云万网虚拟linux主机。

  2. xunruicms 4.3.11,后台跨站验证关闭,自动识别开启

  3. 域名绑定:本站电脑域名www.nngt.com,本站手机域名m.nngt.com,本站其他域名,nngt.com

  4. /.htaccess对于字体跨域如下 :

    <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg|font.css|css)$">

    <IfModule mod_headers.c>

    Header set Access-Control-Allow-Origin "*"

    </IfModule>

    </FilesMatch>

  5. /mobile/.htaccess对于字体跨域同上 :

    <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg|font.css|css)$">

    <IfModule mod_headers.c>

    Header set Access-Control-Allow-Origin "*"

    </IfModule>

    </FilesMatch>

    =============症状1报错:打开移动版页面时,页面红字提示错误如下:


    Access to font at 'http://www.nngt.com/theme1/font_1640804/iconfont.woff2' from origin 'http://m.nngt..com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


    GET http://www.nngt..com/theme1/font_1640804/iconfont.woff2 net::ERR_FAILED


    Access to font at 'http://www.nngt..com/theme1/font_1640804/iconfont.woff' from origin 'http://m.nngt..com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


    GET http://www.nngt..com/theme1/font_1640804/iconfont.woff net::ERR_FAILED


    Access to font at 'http://www.nngt..com/theme1/font_1640804/iconfont.ttf' from origin 'http://m.nngt..com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


    GET http://www.nngt.com/theme1/font_1640804/iconfont.ttf net::ERR_FAILED

    ============症状2:域名识别跳转疑问==============

    手机浏览器输入www.nngt.com/show-xx.com,可自动跳转m.nngt.com/show-xx.com。但换成输入(或打开)不带三大不溜开头的nngt.com/show-xx.com,手机浏览器无法自动跳转到m.nngt.com/show-xx.com



回帖
  • 猪肉贩子
    #1楼    猪肉贩子
    2020-09-06 20:52:45
    Chrome 0
    增加悬赏(设置悬赏)金:5元,希望大家给予帮助!
  • 南哥
    #2楼    南哥
    2020-09-06 20:59:08
    Chrome 0
    虚拟主机要在主机上设置面板里面设置woff扩展名
  • 靠悬赏赚钱买授权
    #3楼    靠悬赏赚钱买授权
    2020-09-06 21:02:34
    Chrome 0

    image
    百度一大堆方案,可以的话给赏金吧
    满意答案
  • 谈笑淡轻云
    #4楼    谈笑淡轻云
    2020-09-06 21:35:42
    Chrome 0
  • 猪肉贩子
    #5楼    猪肉贩子
    2020-09-06 23:14:48
    Chrome 0
    刚开始本机电脑居然不能访问虚拟主机域名,对360浏览器一顿操作之后,能正常访问,字体报错提示也神奇自愈了。以下为原有代码<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{HTTP_HOST} ^m\.nngt\.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/mobile/RewriteRule ^(.*)$ mobile/$1?Rewrite [L,QSA]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L] </IfModule><FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg|font.css|css)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule></FilesMatch>因此赏金只能给第二个问题:域名识别跳转疑问==============手机浏览器输入www.nngt.com/show-xx.com,会自动跳转m.nngt.com/show-xx.com。但换成输入(或打开)不带三大不溜开头的nngt.com/show-xx.com,手机浏览器无法自动跳转到m.nngt.com/show-xx.com

  • 曹海峰
    #6楼    曹海峰
    2020-09-07 08:44:43
    Chrome 0
    你发两个帖子不就行了吗
  • 猪肉贩子
    #7楼    猪肉贩子
    2020-09-07 09:38:39
    Chrome 0
    曹海峰 .htaccess里面既有对字体跨域的设置,也有对域名绑定的代码(可能影响域名跳转)。分开两帖可能顾此失彼,无法兼顾
  • 猪肉贩子
    #8楼    猪肉贩子
    2020-10-26 21:28:24
    Chrome 0
    @靠悬赏(设置悬赏)赚钱买授权:答案不是我想要的。辛苦大家了