How To Allow Iframe Embedding Only For Whitelisted Websites?
I've a form that I'd like to embed in a website, which is on my whitelist. Other websites, that try to embed it, should get only an error page.
Solution 2:
Most browsers will support the X-Frame-Options header.
This header will prevent access:
X-Frame-Options: SAMEORIGIN
And this header to allow access:
X-Frame-Options: ALLOW-FROM [uri]
Examples for the options:
X-Frame-Options: DENYX-Frame-Options: SAMEORIGINX-Frame-Options: ALLOW-FROM https://example.com/
An example in PHP:
<?php header('X-Frame-Options: SAMEORIGIN'); ?>
You can read further here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
Hope it helps a bit!
Post a Comment for "How To Allow Iframe Embedding Only For Whitelisted Websites?"