Skip to content

Instantly share code, notes, and snippets.

@ritou
Created September 19, 2010 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritou/586865 to your computer and use it in GitHub Desktop.
Save ritou/586865 to your computer and use it in GitHub Desktop.
<?php
if( isset($_REQUEST["done"]) && ($_REQUEST["done"] == "http" || $_REQUEST["done"] == "https") ){
$toSecurepage = ( $_REQUEST["done"] == "https" ) ? true : false;
if($toSecurepage){
quietredirector::redirection("https://r-weblife.sakura.ne.jp/php-quietredirection/test.php");
}else{
quietredirector::redirection("http://r-weblife.sakura.ne.jp/php-quietredirection/test.php");
}
}else{
print "error.";
}
class quietredirector{
public static function redirection($url){
$urlpart = parse_url($url);
if(isset($urlpart["scheme"])){
if($urlpart["scheme"]=="https"){
header("Location: ".$url);
}else{
self::displayHtml($url);
}
}
}
private static function displayHtml($url){
$html = <<<HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
<!--
window.location.replace("$url");
// -->
</script>
<meta http-equiv="Refresh" content="0; url=$url">
</head>
<body>
<a href="$url">$url</a>へジャンプしようとしています。
自動的にページが切り替わらない場合には、<a href="$url">こちら</a>をクリックしてください。</body>
</html>
HTML;
print $html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment