开发者

code to switch to my website

开发者 https://www.devze.com 2023-04-11 21:28 出处:网络
some people puts my website in \" iframe\" in the forums,blogs,..... so i want to make code to switch them to my website.

some people puts my website in " iframe" in the forums,blogs,.....

so i want to make code to switch them to my website.

i try this code but its doesn't work :

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"];
 }
 return $pageURL;
}

$url=curPageURL();

if(!$url == "www.mywebsite.com"){

echo '<META HTT开发者_C百科P-EQUIV="Refresh" CONTENT="0;URL=http://www.mywebsite.com">';
}
?>

thank you


The typical way to do this is using JavaScript, using a "frame buster" script such as:

<script>
if(top != self) top.location.replace(location);
</script>

The code you're using won't work, as server variables such as SERVER_NAME are not affected by whether your site is framed or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号