Block my website from iFrame traffic

In some cases it’s usefull to protect own website from iFrame traffic. Here are 2 solutions.

Protect with PHP

<?php
header('X-Frame-Options: deny');
?>

Protect with Javascript

if (window.top !== window.self) window.top.location.replace(window.self.location.href);
// Not recommend, try using PHP method.

Leave a Reply

Your email address will not be published. Required fields are marked *