限制我的网站嵌入到少数域

Limiting my website embed to only a handful of domains

我有一个网络应用程序,我想将其嵌入到不同的网站上。但是,我不希望嵌入对所有域都可用。所以假设 http://mysite1.com, and http://mysite2.com embeds my website, thats fine, and I want the operations to go smoothly. However, if http://foreignsite.com 嵌入相同的页面,该过程将不起作用。这可能吗?

注意:我在嵌入过程中使用了 iFrame。

添加一个X-Frame-Options HTTP response header:

X-Frame-Options: ALLOW-FROM http://mysite2.com 

将此添加到您的 .htaccess 文件中

SetEnvIf Origin "^http(s)?://(.+\.)?(First-domain\.com|Second-domain\.com)$" origin_is=[=10=] 

Header 总是设置 Access-Control-Allow-Origin %{origin_is}e env=origin_is