我如何有select地使用Apache添加X-Frame-Options?

我打算在我的服务器的httpd.conf设置X-Frame-Options SAMEORIGIN ,作为改善针对点击顶起的防御的一部分。 我知道这会将X-Frame-Options标题添加到所有页面。 有一个“小部件”页面,我想从这个豁免(其他网站将在IFRAME显示此页面)。

有没有办法configurationApache 2不发送一个特定的页面头?

是的,使用SetEnvIf

 SetEnvIf Request_URI "^/my_awesome_widget_page.html$" iframes_are_cool Header set X-Frame-Options SAMEORIGIN env=!iframes_are_cool 

您可以在.htaccess文件中取消设置X-Frame-Options标题(假设您的小部件位于其自己的子目录中):

 Header always unset X-Frame-Options