How to prevent the website from being embedded in frames, iframes, and similar elements?

Website URL

https://freestuff.infinityfree.me/

Error Message

None

Other Information

Hi, I would like to prevent my website from being embedded in frames, iframes, or similar elements on other websites. Could you please guide me on how to block this using the appropriate headers or configurations? Thank you!

Free hosting does that by default.

6 Likes

@Meishin thanks for your clarification. Mind to share the codes needed to prevent iframe just in case the built-in system doesnt works?

I’m pretty sure that system always works.

Unfortunately I’m not a professional at setting these rules so I asked ChatGPT and apparently you need to set some headers with .htaccess:

Header set X-Frame-Options "DENY"
Header set Content-Security-Policy "frame-ancestors 'none';"
7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.