http-equiv="X-UA-兼容" content=“IE=边缘,chrome=1” ...将其放入 .htaccess 中?

发布于 2024-12-06 14:20:18 字数 719 浏览 2 评论 0 原文

我下载了 html5 样板,但它不会在标头中验证此内容。

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >

有人告诉我可以将其添加到 .htaccess 中以获得相同的效果,以避免验证错误。

<IfModule mod_headers.c>
  Header set X-UA-Compatible "IE=Edge,chrome=1"
  # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>

我的问题是

  1. 如何测试以确保其正常工作
  2. filesmatch 参数有什么作用?我应该修改它还是原样就很好?

I downloaded html5 boilerplate and it wouldnt validate with this in the header.

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >

I was told I can add this to .htaccess for the same effect to avoid validation errors.

<IfModule mod_headers.c>
  Header set X-UA-Compatible "IE=Edge,chrome=1"
  # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>

My question is

  1. How do i test to make sure this is working properly
  2. What does the filesmatch parameter do? should i be modifying that or is that pretty good as-is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

始于初秋 2024-12-13 14:20:18

尝试通过 web.config 或 htacess 文件

Web.Config

<httpProtocol>
  <customHeaders>
    <clear />
    <add name="X-UA-Compatible" value="IE=Edge,chrome=1" />
  </customHeaders>
</httpProtocol>

传递它,之后您的页面将有效。抱歉,我不是 php 人。

Try to pass it through the web.config or htacess file

Web.Config

<httpProtocol>
  <customHeaders>
    <clear />
    <add name="X-UA-Compatible" value="IE=Edge,chrome=1" />
  </customHeaders>
</httpProtocol>

your page will be valid after that. Sorry I am not a php guy.

月隐月明月朦胧 2024-12-13 14:20:18

我发现的最好的 htaccess 配置是下面这个:

<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    BrowserMatch MSIE ie
    Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
  </IfModule>
</IfModule>

因为它只为 IE 浏览器发送标头。

The best htaccess configuration that I found is this one below:

<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    BrowserMatch MSIE ie
    Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
  </IfModule>
</IfModule>

Because it sends the header just for IE browsers.

但可醉心 2024-12-13 14:20:18

http://www.validatethis.co.uk/tag/x-ua-兼容/

Aaron Layton 已经听到了:) 只需向下滚动到“修复”并跳过以上所有内容:)

或者您可以将其添加到您的 .htaccess 文件中,如下所示:

<FilesMatch "\.(htm|html|php)$">
    <IfModule mod_headers.c>
        BrowserMatch MSIE ie
        Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
    </IfModule>
</FilesMatch>

http://www.validatethis.co.uk/tag/x-ua-compatible/

Aaron Layton has it all hear :) Just Scroll down to the "The fix" and skip all the above :)

Or you could add it to your .htaccess file like this:

<FilesMatch "\.(htm|html|php)$">
    <IfModule mod_headers.c>
        BrowserMatch MSIE ie
        Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
    </IfModule>
</FilesMatch>
吹梦到西洲 2024-12-13 14:20:18

我如何测试以确保其正常工作

向 URI 发出请求并查看响应标头。有很多工具可以做到这一点,包括 Charles Proxy、Firebug 和 Chrome 开发者工具。

filesmatch 参数有什么作用?

手册中有描述

How do i test to make sure this is working properly

Make a request to a URI and look at the response headers. There are plenty of tools to do that, including Charles Proxy, Firebug and Chrome Developer Tools.

What does the filesmatch parameter do?

It is described in the manual

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文