如何仅在为其创建小部件的域上呈现小部件


How to render a widget only on the domain for which it is created

我有一个小部件(在Apache Web服务器上用PHP构建),它嵌入在其他网站的网页上。

我想只在为其构建小部件的页面上呈现小部件。

例如,如果小部件用于网站example-a.com,并且它嵌入在域example-b.com上,我希望它不显示在example-b.com中。有可能做这样的事吗?

也许使用http_referer我可以解决问题?

为了嵌入小部件,我使用了iframe,但我不确定http_referer是否可以破解。

iframe是这样的:

<iframe id="WidgetContent" src="http://127.0.0.1:8000/widget/1" frameborder="0" height="600"></iframe>

因此没有使用javascript。

对此有什么建议吗?非常感谢。

您可以指定允许哪些站点使用X-Frame-Options HTTP响应标头在框架中显示页面。

X-Frame-Options: http://example-a.com