Search code examples
htmliframeresponsehttpresponse

How would set a response header X-Frame-Options?


I need help with setting a response header for my site, hosted on Github pages. How would I set the X-Frame-Options option to DENY? I could use HTML, CSS, JS, or PHP.

I have tried using <meta http-equiv="X-Frame-Options" content="deny"> but I got this message in console:

X-Frame-Options may only be set via an HTTP header sent along with a document. It may not be set inside <meta>.

UPDATE

Since I can not edit the headers because my site is hosted on GitHub, is there a way to check if the page is in an iframe and display an image instead of the content?

Any ideas are appreciated!


Solution

  • You can't.

    Github pages does not provide any mechanism for customising HTTP response headers (including running server-side code in any programming language).