Asked 2 years ago
15 Apr 2022
Views 567
steave

steave posted

How to secure Content Sniffing in php ?

how to set X-Content-Type-Options to nosniff ?

I am using PHP as server-side language, so I want to know how to enable X-Content-Type-Options to nosniff with PHP?
dilip

dilip
answered Apr 15 '22 00:00

put below code to at php file before sending header or content

header('X-Content-Type-Options: nosniff');

PHP has the header() function which sends the header as per need. so we are using the header function to send X-Content-Type-Options: nosniff to the browser.
sachin

sachin
answered Apr 15 '22 00:00

please do the below change in .htaccess to set HTTP header with the value nosniff set in the response.

Header set X-Content-Type-Options "nosniff"
Post Answer