Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1578688
  • 博文数量: 50
  • 博客积分: 9971
  • 博客等级: 中将
  • 技术积分: 2615
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-03 16:03
文章分类

全部博文(50)

文章存档

2011年(2)

2010年(2)

2009年(41)

2008年(5)

我的朋友

分类:

2009-03-31 10:49:51

<?php
header("HTTP/1.0 404 Not Found");
include("/var/www/html/site.domain.com/err/404.php");
?>


Reference:




<?php
//This works in 5.2.3

//First function turns SSL on if it is off.

//Second function detects if SSL is on, if it is, turns it off.


//==== Redirect... Try PHP header redirect, then Java redirect, then try http redirect.:

function redirect($url){
    if (!headers_sent()){ //If headers not sent yet... then do php redirect

        header('Location: '.$url); exit;
    }else{ //If headers are sent... do java redirect... if java disabled, do html redirect.

        echo '';
        echo ''; exit;
    }
}//==== End -- Redirect


//==== Turn on HTTPS - Detect if HTTPS, if not on, then turn on HTTPS:

function SSLon(){
    if($_SERVER['HTTPS'] != 'on'){
        $url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        redirect($url);
    }
}//==== End -- Turn On HTTPS


//==== Turn Off HTTPS -- Detect if HTTPS, if so, then turn off HTTPS:

function SSLoff(){
    if($_SERVER['HTTPS'] == 'on'){
        $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        redirect($url);
    }
}//==== End -- Turn Off HTTPS

?>

阅读(755) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~