【发布时间】:2011-10-19 05:29:45
【问题描述】:
我有一个像这样在生产环境中运行的 PHP 应用程序:
<?php
/*
Do some work here
*/
/* if https environment, redirect to secure next url */
if(empty(isset["HTTPS"]) == true ) /* FIRST DEPENDECY */
{
header("location : https://mynext_prod_url?parameters"); /*SECOND DEPENDENCY */
}
else
{
header("location : http://mynext_prod_url?parameters");
}
?>
这在安装了 SSL 证书的生产环境中工作得非常好。 为了在开发中模拟相同的场景,我可以克服第一个依赖, 但是我该如何克服第二个呢?
/* 带有变通方法的开发示例 */
<?php
/*
Do some work here
*/
$_SERVER['HTTPS'] = "TRUE" ; /* fake HTTPS */
if(isset($_SERVER["HTTPS"]) == true ) /* FIRST DEPENDECY SOLVED */
{
/* BUT THIS URL DOES NOT WORK AS IT ONLY EXISTS ON HTTP */
header("location : https://mynext_dev_url?parameters");
}
else
{
header("location : http://mynext_dev_url?parameters");
}
?>
如何为开发目的安装临时证书? 或者以某种方式伪造环境。
【问题讨论】: