如何在我的网站中实现HTTP标头?

用户名

我在漏洞检查器上审核了我的网站,并建议我需要添加安全标头。

XSS Protection缺少安全标头。

缺少安全标头以防止内容类型嗅探。

缺少Strict-Transport-Security安全标头。

泄漏的PHP版本。您的网站在https://www.mywebsite.com/blog/上的HTTP标头中显示您的PHP版本请设置Exposure_php = Off。

我进入了htaccess文件,并尝试添加一些本网站推荐的标题,是我尝试过的方法:

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

上面的代码适用于除/ blog子域之外的所有其他内容,该子域顺带托管在CMS上。

当我在下面添加标题时,我的网站立即停止工作。

Strict-Transport-Security: max-age= Strict-Transport-Security: max-age=; 
includeSubDomains Strict-Transport-Security: max-age=; preload

我在这方面完全没有经验,并且想要删除审核网站发现的所有漏洞。

用户名

我将此代码添加到htaccess文件中,并重新扫描了网站,问题已解决。

<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block" //help protect against XSS
Header always append X-Frame-Options SAMEORIGIN //help protect against page-framing and clickjacking
Header set X-Content-Type-Options nosniff //help protect against content-sniffin
Header add Strict-Transport-Security "max-age=31415926;includeSubDomains;"//I believe this adds https before the domain on all pages.

</IfModule>

<IfModule mod_php5.c>
php_flag expose_php off //This stop divulging the php version
</IfModule>

转到此处获取更简洁的详细信息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章