文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Sending a 404 header with PHP

Sending a 404 header with PHP

时间:2009-03-31  来源:windlike

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


Reference:
http://www.webmasterworld.com/forum88/784.htm
http://hk2.php.net/header

<?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 '<noscript>';
        echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
        echo '</noscript>'; 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

?>

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载