仅允许通过IFRAME访问 [英] Allow access only through iframe

查看:224
本文介绍了仅允许通过IFRAME访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图阻止直接访问我的网站页面。从一个iframe只允许访问的。示例

I'm trying to block direct access to the pages of my site. Only access from an iframe should be allowed. Example

IFRAME页面 - > /path/to/iframe.html

iframe page -> /path/to/iframe.html

anyotherpage.html->应该是可见的,只有从iframe.html的iframe

anyotherpage.html-> should be visible only from the iframe in iframe.html

有没有什么办法与htaccess的实现这一目标?

Is there any way to achieve this with htaccess?

推荐答案

您可以尝试检查%{HTTP_REFERER}

RewriteCond %{HTTP_REFERER} your\.domain/iframe\.php
RewriteCond %{REQUEST_URI} ^/iframe.html
RewriteRule ^(.*)$ - [L]

RewriteCond %{HTTP_REFERER} !your\.domain/iframe\.php
RewriteCond %{REQUEST_URI} ^/iframe.html
RewriteRule ^(.*)$ /another_page [R,L]

在此规则的 iframe.php =与位于iframe标签页。 iframe.html =它使用的iframe的页面

In this rules iframe.php = page with iframe tag located. iframe.html = page which using as iframe

所以,如果你尝试请求 iframe.html 直接,你会得到重定向到另一个页面。

So, if you try to request iframe.html directly, you will get redirect to another page.

这篇关于仅允许通过IFRAME访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆