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.
精彩评论