1

如果我使用某个控制器,我想将我的应用程序从 http 重定向到 https。我该怎么做?我真的不想要 .htaccess 重写,因为我使用了很多 Zend 路由,最好是我想要 Zend 中可以做到的方法

4

1 回答 1

0

如果要对控制器内的所有操作执行此操作,可以init()使用控制器的_redirect()函数在函数中执行重定向:

class MyController extends Zend_Controller_Action
{
    public function init()
    {
        $this->_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
    }
}
于 2012-10-02T13:23:06.037 回答