1.  最近在写PHP程序时,需要使浏览器在https和http之间转化,上网搜索相关信息,无奈只有最近在写PHP程序时,需要使浏览器在https和http之间转化,上网搜索相关信息,无奈只有一篇介绍用ASP实现“在http和https之间转化”的文章,于是只好行写了用PHP实现http与https转化的代码。 
  2.   如果网页使用https访问,在网页开头加入以下代码: 
  3. view plainprint? 
  4. <?php   
  5. //http转化为https    
  6. if ($_SERVER["HTTPS"]<>"on")   
  7. {   
  8. $xredir="https://".$_SERVER["SERVER_NAME"].   
  9. $_SERVER["REQUEST_URI"];   
  10. header("Location: ".$xredir);   
  11. }    
  12. ?>   
  13.  
  14.   如果网页使用http访问,在网页开头加入以下代码: 
  15. view plainprint? 
  16. <?php   
  17. //https转化为http    
  18. if ($_SERVER["HTTPS"]=="on")   
  19. {   
  20. $xredir="http://".$_SERVER["SERVER_NAME"].   
  21. $_SERVER["REQUEST_URI"];   
  22. header("Location: ".$xredir);   
  23. }    
  24. ?>