简体   繁体   English

框架到htaccess或php重定向

[英]frame to htaccess or php redirect

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) 我有一个指向我主域的域,但是他使用框架(我无法更改此域,我的主机仅提供这种重定向,甚至不允许我重定向到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 不能更改主机

This is possible only with a Javascript-based frame buster . 这仅适用于基于Javascript的帧破坏程序

A primitive version: 原始版本:

<script type="text/javascript">
  if(top != self) top.location.replace("http://maindomain.com");
</script>

@thejh: Break out of the frame ? @thejh:跳出frame吗?

<script type="text/javascript">
<!--
if (top.location != self.location) top.location = self.location;
// -->
</script>

after trying for a day I found the solution without javascript! 尝试了一天后,我找到了没有javascript的解决方案!

It uses htaccess only, and I put it in the directory where I point my frame: 它仅使用htaccess,并将其放在指向框架的目录中:

  RewriteCond %{HTTP_REFERER} !^http://www\.ethicsoft\.it/(.*)$
  RewriteRule ^(.*) http://www.ethicsoft.it/$1 [R=301,NC]

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! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM