仅允许通过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.