框架到 htaccess 或 php 重定向
我有一个指向我的主域名的域名,但他使用了一个框架(我无法更改这一点,我的主机只提供这种类型的重定向,甚至不允许我重定向到redirect.html)
<FRAME SRC="http://www.domain111.com/" NORESIZE>
我如何强制这个辅助域名重定向到我的主网站,没有框架? 到目前为止我尝试过:
RewriteCond %{HTTP_HOST} ^www.domain222.com$[OR]
RewriteCond %{HTTP_HOST} ^domain222.com$
RewriteRule ^(.*)$ http://www.domain111.com/$1 [R=301,L]
但是
if (preg_match("/domain2222.com/i", $_SERVER['HTTP_REFERER'])) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.domain111.com/");
exit;
}
那是一个无限循环,因为重定向来自该框架
我应该做什么?更改主机不是一个选项
i have a domain pointing to my main, but hes using a frame (i cant change this, my host only provides this type of redirect and dont even allow me to redirect to a redirect.html)
<FRAME SRC="http://www.domain111.com/" NORESIZE>
how can i force this secondary domain to redirect to my main site, without frames?
so far i tried:
RewriteCond %{HTTP_HOST} ^www.domain222.com$[OR]
RewriteCond %{HTTP_HOST} ^domain222.com$
RewriteRule ^(.*)$ http://www.domain111.com/$1 [R=301,L]
also
if (preg_match("/domain2222.com/i", $_SERVER['HTTP_REFERER'])) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.domain111.com/");
exit;
}
but thats a infinite loop since the redirect comes from that frame
what should i do? changing host is not a option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这只能通过基于 Javascript 的 frame buster 实现。
原始版本:
This is possible only with a Javascript-based frame buster.
A primitive version:
@thejh:突破
框架
?@thejh: Break out of the
frame
?经过一天的尝试,我找到了无需 javascript 的解决方案!
它仅使用 htaccess,并将其放在指向框架的目录中:
它对我有用,但我建议使用浏览器和域提供商与框架的不同组合进行一些测试,因为它完全取决于传递的引用值到加框页面。
希望有帮助!
after trying for a day I found the solution without javascript!
It uses htaccess only, and I put it in the directory where I point my frame:
it worked for me, but I suggest to make some test with different combination of browsers and domain providers with frames, because it totally depends on the referer value passed to the framed page.
hoping is helpful!