为所有支持它的浏览器设置 nosniff header 除了 IE11
Set nosniff header for all the browsers that support it except IE11
在我的 .htaccess 文件中有
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
Header always set X-Content-Type-Options nosniff
</IfModule>
它为所有支持它的浏览器设置 nosniff header。
我想为除 IE11 之外的所有支持它的浏览器设置 nosniff header。我在 CentOS 上使用 Apache/2.2.23。
可能吗?
提前致谢。
简答:你不能
长答案:理论上您应该能够使用如下内容:
BrowserMatch "MSIE 11.0;" allow_sniff
Header set X-Content-Type-Options: nosniff env=!allow_sniff
但是 IE11 故意掩盖它 user-agent 伪装成其他东西。有关详细信息,请参阅此 post:http://blogs.msdn.com/b/ieinternals/archive/2013/09/21/internet-explorer-11-user-agent-string-ua-string-sniffing-compatibility-with-gecko-webkit.aspx
所以最终上面的方法是行不通的。相反,您应该修复需要更改 IE11 行为的原因(修复您的 dupal 模块,或关闭所有浏览器的无嗅探)。
您可以通过修改 Apache 设置或 .htaccess 文件并向其中添加以下行来启用它:
Header 设置 X-Content-Type-Options nosniff
Microsoft 的这篇文章对其进行了解释:降低 MIME 类型安全风险
http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx
在我的 .htaccess 文件中有
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
Header always set X-Content-Type-Options nosniff
</IfModule>
它为所有支持它的浏览器设置 nosniff header。
我想为除 IE11 之外的所有支持它的浏览器设置 nosniff header。我在 CentOS 上使用 Apache/2.2.23。 可能吗?
提前致谢。
简答:你不能
长答案:理论上您应该能够使用如下内容:
BrowserMatch "MSIE 11.0;" allow_sniff
Header set X-Content-Type-Options: nosniff env=!allow_sniff
但是 IE11 故意掩盖它 user-agent 伪装成其他东西。有关详细信息,请参阅此 post:http://blogs.msdn.com/b/ieinternals/archive/2013/09/21/internet-explorer-11-user-agent-string-ua-string-sniffing-compatibility-with-gecko-webkit.aspx
所以最终上面的方法是行不通的。相反,您应该修复需要更改 IE11 行为的原因(修复您的 dupal 模块,或关闭所有浏览器的无嗅探)。
您可以通过修改 Apache 设置或 .htaccess 文件并向其中添加以下行来启用它:
Header 设置 X-Content-Type-Options nosniff
Microsoft 的这篇文章对其进行了解释:降低 MIME 类型安全风险 http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx